outline_panel_settings.rs

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