-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Bring Jupyter to Zed Editing #12062
Bring Jupyter to Zed Editing #12062
Conversation
c0a8895
to
e4524e5
Compare
e8eb9d4
to
9398745
Compare
Hi! Great job, man. When this will be merged and released I will drop VSCode forever. Some reminders that you probably missed in your TODOs:
And again, great job! |
That rocks. There are more improvements to make here that are going to need help in GPUI land, mostly since this isn't a browser. I'll have to review what else is in #9778 as I flesh this first version out.
Magics and shell commands work out of the box with IPython (and other kernels that have them): However, completions are not hooked up. I'll leave that as an exercise for a future contributor so we can have the basics soon.
Thank you! Bonus as of now -- plots (and images) are working: plots.mp4 |
Amazing! Thank you for creating this. By any chance could you add support to Ruby? |
Support should be built in but there's some issues on the ruby jupyter kernel. Would you be interested in helping them bring the kernel up to date? SciRuby/iruby#340 |
Yikes, looks like I need some way to handle when more than 256 lines come in. We need a scrollable output area when that happens or we have to trim it. |
crates/runtimes/src/outputs.rs
Outdated
pub status: ExecutionStatus, | ||
} | ||
|
||
pub fn svg_to_vec(text: &str, scale: f32) -> Result<OutputType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the impression that the GPUI image view can already render SVGs and SVG files are just forced to use the text editor instead of the image preview because people want to edit them. Could that functionality be reused here instead of reimplementing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, shipping the initial version without SVG and later improving the already existing image view to handle the needed SVG features sounds like a preferrable approach to me.
d4b081e
to
4ac882c
Compare
I'm going on vacation this coming week so I'll just post a few in-progress details here:
|
Heads-up: I needed the block resize feature, so I pulled those changes into |
Rad, glad to see that landed. |
Alright I'm back from vacation and ready for the next phase of this PR. I want to get all the tasks that are spawned to listen for events for each execution view to instead get turned into one listener that will route messages to the right execution view. In order to do that, I'll need the runtime manager (model) to push execution requests over to a model that will emit events targeting a view for the session. |
assets/keymaps/default-macos.json
Outdated
// Bindings for running code in the editor | ||
"cmd-enter": "repl::Run" | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to take these out for now to make this feature opt-in for now.
I've opted to bring this in behind a feature flag. It's not ready for primetime just yet. Follow on PRs will be coming. |
Run any Jupyter kernel in Zed on any buffer (editor): <img width="1074" alt="image" src="https://github.com/zed-industries/zed/assets/836375/eac8ed69-d02b-4d46-b379-6186d8f59470"> ## TODO ### Lifecycle * [x] Launch kernels on demand * [x] Wait for kernel to be started * [x] Request Kernel info on start * [x] Show in progress indicator * [ ] Allow picking kernel (it defaults to first matching language name) * [ ] Menu for interrupting and shutting down the kernel * [ ] Drop running kernels once editor is dropped ### Media Outputs * [x] Render text and tracebacks with ANSI color handling * [x] Render markdown as text * [x] Render PNG and JPEG images using an explicit height based on line-height * ~~Render SVG~~ -- not happening for this PR due to lack of text in SVG support * [ ] Process `update_display_data` message and related `display_id` * [x] Process `page` data from payloads as outputs * [ ] Render markdown as, well, rendered markdown -- Note: unsure if we can get line heights here ### Document * [x] Select code and run * [x] Run current line * [x] Clear previous overlapping runs * [ ] Support running markdown code blocks * [ ] Action to export session as notebook or output files * [ ] Action to clear all outputs * [ ] Delete outputs when lines are deleted ## Other missing features The following is a list of missing functionality or expectations that are out of scope for this PR. ### Python Environments Detecting python environments should probably be done in a separate PR in tandem with how they're used with LSP. Users likely want to pick an environment for their project, whether a virtualenv, conda env, pyenv, poetry backed virtualenv, or the system. Related issues: * zed-industries#7646 * zed-industries#7808 * zed-industries#7296 ### LSP Integration * Submit `complete_request` messages for completions to interleave interactive variables with LSP * LSP for IPython semantics (`%%timeit`, `!ls`, `get_ipython`, etc.) ## Future release notes - Run code in any editor, whether it's a script or a markdown document Release Notes: - N/A
This is really great, thank you! I wonder, would one be able to use/adapt this for marimo support as well? |
Hey man, any updates on how we can get this? Even the test version so far looks amazing to use |
Looking to ship this in the next couple weeks. Refining the UI for active kernels at the moment and introducing some ways to configure default kernels in #13625. |
Initial runtimes UI panel. The main draw here is that all message subscription occurs with two background tasks that run for the life of the kernel. Follow on to #12062 * [x] Disable previous cmd-enter behavior only if runtimes are enabled in settings * [x] Only show the runtimes panel if it is enabled via settings * [x] Create clean UI for the current sessions ### Running Kernels UI <img width="205" alt="image" src="https://github.com/zed-industries/zed/assets/836375/814ae79b-0807-4e23-bc95-77ce64f9d732"> * [x] List running kernels * [x] Implement shutdown * [x] Delete connection file on `drop` of `RunningKernel` * [x] Implement interrupt #### Project-specific Kernel Settings - [x] Modify JupyterSettings to include a `kernel_selections` field (`HashMap<String, String>`). - [x] Implement saving and loading of kernel selections to/from `.zed/settings.json` (by default, rather than global settings?) #### Kernel Selection Persistence - [x] Save the selected kernel for each language when the user makes a choice. - [x] Load these selections when the RuntimePanel is initialized. #### Use Selected Kernels - [x] Modify kernel launch to use the selected kernel for the detected language. - [x] Fallback to default behavior if no selection is made. ### Empty states - [x] Create helpful UI for when the user has 0 kernels they can launch and/or 0 kernels running <img width="694" alt="image" src="https://github.com/zed-industries/zed/assets/836375/d6a75939-e4e4-40fb-80fe-014da041cc3c"> ## Future work ### Kernel Discovery - Improve the kernel discovery process to handle various installation methods (system, virtualenv, poetry, etc.). - Create a way to refresh the available kernels on demand ### Documentation: - Update documentation to explain how users can configure kernels for their projects. - Provide examples of .zed/settings.json configurations for kernel selection. ### Kernel Selection UI - Implement a new section in the RuntimePanel to display available kernels. - Group on the language name from the kernel specification - Create a dropdown for each language group to select the default kernel. Release Notes: - N/A --------- Co-authored-by: Kirill <kirill@zed.dev>
Run any Jupyter kernel in Zed on any buffer (editor):
TODO
Lifecycle
Media Outputs
page
data from payloads as outputsDocument
Other missing features
The following is a list of missing functionality or expectations that are out of scope for this PR.
Python Environments
Detecting python environments should probably be done in a separate PR in tandem with how they're used with LSP. Users likely want to pick an environment for their project, whether a virtualenv, conda env, pyenv, poetry backed virtualenv, or the system. Related issues:
LSP Integration
complete_request
messages for completions to interleave interactive variables with LSP%%timeit
,!ls
,get_ipython
, etc.)Future release notes
Release Notes: