project_panel_settings.rs

 1use anyhow;
 2use schemars::JsonSchema;
 3use serde_derive::{Deserialize, Serialize};
 4use settings::Setting;
 5
 6#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
 7#[serde(rename_all = "snake_case")]
 8pub enum ProjectPanelDockPosition {
 9    Left,
10    Right,
11}
12
13#[derive(Deserialize, Debug)]
14pub struct ProjectPanelSettings {
15    pub default_width: f32,
16    pub dock: ProjectPanelDockPosition,
17    pub file_icons: bool,
18    pub folder_icons: bool,
19    pub git_status: bool,
20    pub indent_size: f32,
21    pub auto_reveal_entries: bool,
22}
23
24#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
25pub struct ProjectPanelSettingsContent {
26    pub default_width: Option<f32>,
27    pub dock: Option<ProjectPanelDockPosition>,
28    pub file_icons: Option<bool>,
29    pub folder_icons: Option<bool>,
30    pub git_status: Option<bool>,
31    pub indent_size: Option<f32>,
32    pub auto_reveal_entries: Option<bool>,
33}
34
35impl Setting for ProjectPanelSettings {
36    const KEY: Option<&'static str> = Some("project_panel");
37
38    type FileContent = ProjectPanelSettingsContent;
39
40    fn load(
41        default_value: &Self::FileContent,
42        user_values: &[&Self::FileContent],
43        _: &gpui::AppContext,
44    ) -> anyhow::Result<Self> {
45        Self::load_via_json_merge(default_value, user_values)
46    }
47}