project_panel_settings.rs

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