outline_panel_settings.rs

 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 indent_guides: bool,
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    /// Customize 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 show indent guides in the outline panel.
58    ///
59    /// Default: true
60    pub indent_guides: Option<bool>,
61    /// Whether to reveal it in the outline panel automatically,
62    /// when a corresponding project entry becomes active.
63    /// Gitignored entries are never auto revealed.
64    ///
65    /// Default: true
66    pub auto_reveal_entries: Option<bool>,
67    /// Whether to fold directories automatically
68    /// when directory has only one directory inside.
69    ///
70    /// Default: true
71    pub auto_fold_dirs: Option<bool>,
72}
73
74impl Settings for OutlinePanelSettings {
75    const KEY: Option<&'static str> = Some("outline_panel");
76
77    type FileContent = OutlinePanelSettingsContent;
78
79    fn load(
80        sources: SettingsSources<Self::FileContent>,
81        _: &mut gpui::AppContext,
82    ) -> anyhow::Result<Self> {
83        sources.json_merge()
84    }
85}