project_panel_settings.rs

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