1use collections::HashMap;
2
3use editor::EditorSettings;
4use gpui::App;
5use settings::Settings;
6
7#[derive(Debug, Default)]
8pub struct JupyterSettings {
9 pub kernel_selections: HashMap<String, String>,
10}
11
12impl JupyterSettings {
13 pub fn enabled(cx: &App) -> bool {
14 // In order to avoid a circular dependency between `editor` and `repl` crates,
15 // we put the `enable` flag on its settings.
16 // This allows the editor to set up context for key bindings/actions.
17 EditorSettings::jupyter_enabled(cx)
18 }
19}
20
21impl Settings for JupyterSettings {
22 fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
23 let jupyter = content.editor.jupyter.clone().unwrap();
24 Self {
25 kernel_selections: jupyter.kernel_selections.unwrap_or_default(),
26 }
27 }
28
29 fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
30 let Some(jupyter) = content.editor.jupyter.as_ref() else {
31 return;
32 };
33 if let Some(kernel_selections) = jupyter.kernel_selections.clone() {
34 self.kernel_selections.extend(kernel_selections)
35 }
36 }
37}