repl: Enable jupyter by default, allow disabling (#14985)
Enables the jupyter feature by default, which is shown only when we have a kernelspec or know that we (can) support it well (Python, Deno/TypeScript). Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
a9397834eb
commit
01392c1329
4 changed files with 29 additions and 44 deletions
|
@ -890,6 +890,15 @@
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
|
// Jupyter settings
|
||||||
|
"jupyter": {
|
||||||
|
"enabled": true
|
||||||
|
// Specify the language name as the key and the kernel name as the value.
|
||||||
|
// "kernel_selections": {
|
||||||
|
// "python": "conda-base"
|
||||||
|
// "typescript": "deno"
|
||||||
|
// }
|
||||||
|
},
|
||||||
// Vim settings
|
// Vim settings
|
||||||
"vim": {
|
"vim": {
|
||||||
"use_system_clipboard": "always",
|
"use_system_clipboard": "always",
|
||||||
|
|
|
@ -1953,7 +1953,7 @@ impl Editor {
|
||||||
EditorMode::Full => "full",
|
EditorMode::Full => "full",
|
||||||
};
|
};
|
||||||
|
|
||||||
if EditorSettings::get_global(cx).jupyter.enabled {
|
if EditorSettings::jupyter_enabled(cx) {
|
||||||
key_context.add("jupyter");
|
key_context.add("jupyter");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ pub struct EditorSettings {
|
||||||
pub search_wrap: bool,
|
pub search_wrap: bool,
|
||||||
pub auto_signature_help: bool,
|
pub auto_signature_help: bool,
|
||||||
pub show_signature_help_after_edits: bool,
|
pub show_signature_help_after_edits: bool,
|
||||||
#[serde(default)]
|
|
||||||
pub jupyter: Jupyter,
|
pub jupyter: Jupyter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,15 +68,23 @@ pub enum DoubleClickInMultibuffer {
|
||||||
Open,
|
Open,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
pub struct Jupyter {
|
pub struct Jupyter {
|
||||||
/// Whether the Jupyter feature is enabled.
|
/// Whether the Jupyter feature is enabled.
|
||||||
///
|
///
|
||||||
/// Default: `false`
|
/// Default: true
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub struct JupyterContent {
|
||||||
|
/// Whether the Jupyter feature is enabled.
|
||||||
|
///
|
||||||
|
/// Default: true
|
||||||
|
pub enabled: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||||
pub struct Toolbar {
|
pub struct Toolbar {
|
||||||
pub breadcrumbs: bool,
|
pub breadcrumbs: bool,
|
||||||
|
@ -247,7 +254,7 @@ pub struct EditorSettingsContent {
|
||||||
pub show_signature_help_after_edits: Option<bool>,
|
pub show_signature_help_after_edits: Option<bool>,
|
||||||
|
|
||||||
/// Jupyter REPL settings.
|
/// Jupyter REPL settings.
|
||||||
pub jupyter: Option<Jupyter>,
|
pub jupyter: Option<JupyterContent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toolbar related settings
|
// Toolbar related settings
|
||||||
|
@ -318,6 +325,12 @@ pub struct GutterContent {
|
||||||
pub folds: Option<bool>,
|
pub folds: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl EditorSettings {
|
||||||
|
pub fn jupyter_enabled(cx: &AppContext) -> bool {
|
||||||
|
EditorSettings::get_global(cx).jupyter.enabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Settings for EditorSettings {
|
impl Settings for EditorSettings {
|
||||||
const KEY: Option<&'static str> = None;
|
const KEY: Option<&'static str> = None;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ impl JupyterSettings {
|
||||||
// In order to avoid a circular dependency between `editor` and `repl` crates,
|
// In order to avoid a circular dependency between `editor` and `repl` crates,
|
||||||
// we put the `enable` flag on its settings.
|
// we put the `enable` flag on its settings.
|
||||||
// This allows the editor to set up context for key bindings/actions.
|
// This allows the editor to set up context for key bindings/actions.
|
||||||
EditorSettings::get_global(cx).jupyter.enabled
|
EditorSettings::jupyter_enabled(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,40 +61,3 @@ impl Settings for JupyterSettings {
|
||||||
Ok(settings)
|
Ok(settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use gpui::{AppContext, UpdateGlobal};
|
|
||||||
use settings::SettingsStore;
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[gpui::test]
|
|
||||||
fn test_deserialize_jupyter_settings(cx: &mut AppContext) {
|
|
||||||
let store = settings::SettingsStore::test(cx);
|
|
||||||
cx.set_global(store);
|
|
||||||
|
|
||||||
EditorSettings::register(cx);
|
|
||||||
JupyterSettings::register(cx);
|
|
||||||
|
|
||||||
assert_eq!(JupyterSettings::enabled(cx), false);
|
|
||||||
|
|
||||||
// Setting a custom setting through user settings
|
|
||||||
SettingsStore::update_global(cx, |store, cx| {
|
|
||||||
store
|
|
||||||
.set_user_settings(
|
|
||||||
r#"{
|
|
||||||
"jupyter": {
|
|
||||||
"enabled": true,
|
|
||||||
"dock": "left",
|
|
||||||
"default_width": 800.0
|
|
||||||
}
|
|
||||||
}"#,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
});
|
|
||||||
|
|
||||||
assert_eq!(JupyterSettings::enabled(cx), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue