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