Bring Jupyter to Zed Editing (#12062)
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: * https://github.com/zed-industries/zed/issues/7646 * https://github.com/zed-industries/zed/issues/7808 * https://github.com/zed-industries/zed/issues/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 commit is contained in:
parent
d95c424d18
commit
221edfc267
15 changed files with 2117 additions and 24 deletions
66
crates/repl/src/runtime_settings.rs
Normal file
66
crates/repl/src/runtime_settings.rs
Normal file
|
@ -0,0 +1,66 @@
|
|||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{Settings, SettingsSources};
|
||||
|
||||
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum RuntimesDockPosition {
|
||||
Left,
|
||||
#[default]
|
||||
Right,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct JupyterSettings {
|
||||
pub enabled: bool,
|
||||
pub dock: RuntimesDockPosition,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
||||
pub struct JupyterSettingsContent {
|
||||
/// Whether the Runtimes feature is enabled.
|
||||
///
|
||||
/// Default: `false`
|
||||
enabled: Option<bool>,
|
||||
/// Where to dock the runtimes panel.
|
||||
///
|
||||
/// Default: `right`
|
||||
dock: Option<RuntimesDockPosition>,
|
||||
}
|
||||
|
||||
impl Default for JupyterSettingsContent {
|
||||
fn default() -> Self {
|
||||
JupyterSettingsContent {
|
||||
enabled: Some(false),
|
||||
dock: Some(RuntimesDockPosition::Right),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Settings for JupyterSettings {
|
||||
const KEY: Option<&'static str> = Some("jupyter");
|
||||
|
||||
type FileContent = JupyterSettingsContent;
|
||||
|
||||
fn load(
|
||||
sources: SettingsSources<Self::FileContent>,
|
||||
_cx: &mut gpui::AppContext,
|
||||
) -> anyhow::Result<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let mut settings = JupyterSettings::default();
|
||||
|
||||
for value in sources.defaults_and_customizations() {
|
||||
if let Some(enabled) = value.enabled {
|
||||
settings.enabled = enabled;
|
||||
}
|
||||
if let Some(dock) = value.dock {
|
||||
settings.dock = dock;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(settings)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue