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