1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use settings::{Settings, SettingsSources};
4
5#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
6#[serde(rename_all = "snake_case")]
7pub enum RuntimesDockPosition {
8 Left,
9 #[default]
10 Right,
11 Bottom,
12}
13
14#[derive(Debug, Default)]
15pub struct JupyterSettings {
16 pub enabled: bool,
17 pub dock: RuntimesDockPosition,
18}
19
20#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
21pub struct JupyterSettingsContent {
22 /// Whether the Runtimes feature is enabled.
23 ///
24 /// Default: `false`
25 enabled: Option<bool>,
26 /// Where to dock the runtimes panel.
27 ///
28 /// Default: `right`
29 dock: Option<RuntimesDockPosition>,
30}
31
32impl Default for JupyterSettingsContent {
33 fn default() -> Self {
34 JupyterSettingsContent {
35 enabled: Some(false),
36 dock: Some(RuntimesDockPosition::Right),
37 }
38 }
39}
40
41impl Settings for JupyterSettings {
42 const KEY: Option<&'static str> = Some("jupyter");
43
44 type FileContent = JupyterSettingsContent;
45
46 fn load(
47 sources: SettingsSources<Self::FileContent>,
48 _cx: &mut gpui::AppContext,
49 ) -> anyhow::Result<Self>
50 where
51 Self: Sized,
52 {
53 let mut settings = JupyterSettings::default();
54
55 for value in sources.defaults_and_customizations() {
56 if let Some(enabled) = value.enabled {
57 settings.enabled = enabled;
58 }
59 if let Some(dock) = value.dock {
60 settings.dock = dock;
61 }
62 }
63
64 Ok(settings)
65 }
66}