1use gpui::Pixels;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4use settings::{Settings, SettingsSources};
5
6#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, Copy, PartialEq)]
7#[serde(rename_all = "snake_case")]
8pub enum OutlinePanelDockPosition {
9 Left,
10 Right,
11}
12
13#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
14pub struct OutlinePanelSettings {
15 pub button: bool,
16 pub default_width: Pixels,
17 pub dock: OutlinePanelDockPosition,
18 pub file_icons: bool,
19 pub folder_icons: bool,
20 pub git_status: bool,
21 pub indent_size: f32,
22 pub auto_reveal_entries: bool,
23 pub auto_fold_dirs: bool,
24}
25
26#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
27pub struct OutlinePanelSettingsContent {
28 /// Whether to show the outline panel button in the status bar.
29 ///
30 /// Default: true
31 pub button: Option<bool>,
32 /// Customize default width (in pixels) taken by outline panel
33 ///
34 /// Default: 240
35 pub default_width: Option<f32>,
36 /// The position of outline panel
37 ///
38 /// Default: left
39 pub dock: Option<OutlinePanelDockPosition>,
40 /// Whether to show file icons in the outline panel.
41 ///
42 /// Default: true
43 pub file_icons: Option<bool>,
44 /// Whether to show folder icons or chevrons for directories in the outline panel.
45 ///
46 /// Default: true
47 pub folder_icons: Option<bool>,
48 /// Whether to show the git status in the outline panel.
49 ///
50 /// Default: true
51 pub git_status: Option<bool>,
52 /// Amount of indentation (in pixels) for nested items.
53 ///
54 /// Default: 20
55 pub indent_size: Option<f32>,
56 /// Whether to reveal it in the outline panel automatically,
57 /// when a corresponding project entry becomes active.
58 /// Gitignored entries are never auto revealed.
59 ///
60 /// Default: true
61 pub auto_reveal_entries: Option<bool>,
62 /// Whether to fold directories automatically
63 /// when directory has only one directory inside.
64 ///
65 /// Default: true
66 pub auto_fold_dirs: Option<bool>,
67}
68
69impl Settings for OutlinePanelSettings {
70 const KEY: Option<&'static str> = Some("outline_panel");
71
72 type FileContent = OutlinePanelSettingsContent;
73
74 fn load(
75 sources: SettingsSources<Self::FileContent>,
76 _: &mut gpui::AppContext,
77 ) -> anyhow::Result<Self> {
78 sources.json_merge()
79 }
80}