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}
22
23#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
24pub struct ProjectPanelSettingsContent {
25    pub default_width: Option<f32>,
26    pub dock: Option<ProjectPanelDockPosition>,
27    pub file_icons: Option<bool>,
28    pub folder_icons: Option<bool>,
29    pub git_status: Option<bool>,
30    pub indent_size: Option<f32>,
31}
32
33impl Setting for ProjectPanelSettings {
34    const KEY: Option<&'static str> = Some("project_panel");
35
36    type FileContent = ProjectPanelSettingsContent;
37
38    fn load(
39        default_value: &Self::FileContent,
40        user_values: &[&Self::FileContent],
41        _: &gpui::AppContext,
42    ) -> anyhow::Result<Self> {
43        Self::load_via_json_merge(default_value, user_values)
44    }
45}