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(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
 14#[serde(rename_all = "snake_case")]
 15pub enum ShowIndentGuides {
 16    Always,
 17    Never,
 18}
 19
 20#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
 21pub struct OutlinePanelSettings {
 22    pub button: bool,
 23    pub default_width: Pixels,
 24    pub dock: OutlinePanelDockPosition,
 25    pub file_icons: bool,
 26    pub folder_icons: bool,
 27    pub git_status: bool,
 28    pub indent_size: f32,
 29    pub indent_guides: IndentGuidesSettings,
 30    pub auto_reveal_entries: bool,
 31    pub auto_fold_dirs: bool,
 32}
 33
 34#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
 35pub struct IndentGuidesSettings {
 36    pub show: ShowIndentGuides,
 37}
 38
 39#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
 40pub struct IndentGuidesSettingsContent {
 41    /// When to show the scrollbar in the outline panel.
 42    pub show: Option<ShowIndentGuides>,
 43}
 44
 45#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
 46pub struct OutlinePanelSettingsContent {
 47    /// Whether to show the outline panel button in the status bar.
 48    ///
 49    /// Default: true
 50    pub button: Option<bool>,
 51    /// Customize default width (in pixels) taken by outline panel
 52    ///
 53    /// Default: 240
 54    pub default_width: Option<f32>,
 55    /// The position of outline panel
 56    ///
 57    /// Default: left
 58    pub dock: Option<OutlinePanelDockPosition>,
 59    /// Whether to show file icons in the outline panel.
 60    ///
 61    /// Default: true
 62    pub file_icons: Option<bool>,
 63    /// Whether to show folder icons or chevrons for directories in the outline panel.
 64    ///
 65    /// Default: true
 66    pub folder_icons: Option<bool>,
 67    /// Whether to show the git status in the outline 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 reveal it in the outline panel automatically,
 76    /// when a corresponding project entry becomes active.
 77    /// Gitignored entries are never auto revealed.
 78    ///
 79    /// Default: true
 80    pub auto_reveal_entries: Option<bool>,
 81    /// Whether to fold directories automatically
 82    /// when directory has only one directory inside.
 83    ///
 84    /// Default: true
 85    pub auto_fold_dirs: Option<bool>,
 86    /// Settings related to indent guides in the outline panel.
 87    pub indent_guides: Option<IndentGuidesSettingsContent>,
 88}
 89
 90impl Settings for OutlinePanelSettings {
 91    const KEY: Option<&'static str> = Some("outline_panel");
 92
 93    type FileContent = OutlinePanelSettingsContent;
 94
 95    fn load(
 96        sources: SettingsSources<Self::FileContent>,
 97        _: &mut gpui::AppContext,
 98    ) -> anyhow::Result<Self> {
 99        sources.json_merge()
100    }
101}