2023-05-23 03:23:07 +00:00
|
|
|
use anyhow;
|
2024-01-03 18:47:33 +00:00
|
|
|
use gpui::Pixels;
|
2023-05-23 03:23:07 +00:00
|
|
|
use schemars::JsonSchema;
|
2023-05-23 03:25:27 +00:00
|
|
|
use serde_derive::{Deserialize, Serialize};
|
2024-01-03 18:47:33 +00:00
|
|
|
use settings::Settings;
|
2023-05-23 03:23:07 +00:00
|
|
|
|
2023-05-23 06:24:28 +00:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
|
|
|
#[serde(rename_all = "snake_case")]
|
|
|
|
pub enum ProjectPanelDockPosition {
|
|
|
|
Left,
|
|
|
|
Right,
|
|
|
|
}
|
|
|
|
|
2023-05-23 03:23:07 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
|
|
|
pub struct ProjectPanelSettings {
|
2024-01-03 18:47:33 +00:00
|
|
|
pub default_width: Pixels,
|
2023-07-20 18:23:47 +00:00
|
|
|
pub dock: ProjectPanelDockPosition,
|
|
|
|
pub file_icons: bool,
|
|
|
|
pub folder_icons: bool,
|
|
|
|
pub git_status: bool,
|
|
|
|
pub indent_size: f32,
|
2023-12-11 21:37:45 +00:00
|
|
|
pub auto_reveal_entries: bool,
|
2023-05-23 03:23:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
|
|
|
pub struct ProjectPanelSettingsContent {
|
2024-01-08 18:30:18 +00:00
|
|
|
/// Customise default width (in pixels) taken by project panel
|
|
|
|
///
|
|
|
|
/// Default: 240
|
2023-05-23 06:24:28 +00:00
|
|
|
pub default_width: Option<f32>,
|
2024-01-08 18:30:18 +00:00
|
|
|
/// The position of project panel
|
|
|
|
///
|
|
|
|
/// Default: left
|
2023-07-20 18:23:47 +00:00
|
|
|
pub dock: Option<ProjectPanelDockPosition>,
|
2024-01-08 18:30:18 +00:00
|
|
|
/// Whether to show file icons in the project panel.
|
|
|
|
///
|
|
|
|
/// Default: true
|
2023-07-20 18:23:47 +00:00
|
|
|
pub file_icons: Option<bool>,
|
2024-01-08 18:30:18 +00:00
|
|
|
/// Whether to show folder icons or chevrons for directories in the project panel.
|
|
|
|
///
|
|
|
|
/// Default: true
|
2023-07-20 18:23:47 +00:00
|
|
|
pub folder_icons: Option<bool>,
|
2024-01-08 18:30:18 +00:00
|
|
|
/// Whether to show the git status in the project panel.
|
|
|
|
///
|
|
|
|
/// Default: true
|
2023-07-20 18:23:47 +00:00
|
|
|
pub git_status: Option<bool>,
|
2024-01-08 18:30:18 +00:00
|
|
|
/// Amount of indentation (in pixels) for nested items.
|
|
|
|
///
|
|
|
|
/// Default: 20
|
2023-07-20 18:23:47 +00:00
|
|
|
pub indent_size: Option<f32>,
|
2024-01-08 18:30:18 +00:00
|
|
|
/// Whether to reveal it in the project panel automatically,
|
|
|
|
/// when a corresponding project entry becomes active.
|
|
|
|
/// Gitignored entries are never auto revealed.
|
|
|
|
///
|
|
|
|
/// Default: true
|
2023-12-11 21:37:45 +00:00
|
|
|
pub auto_reveal_entries: Option<bool>,
|
2023-05-23 03:23:07 +00:00
|
|
|
}
|
|
|
|
|
2024-01-03 18:47:33 +00:00
|
|
|
impl Settings for ProjectPanelSettings {
|
2023-05-23 03:23:07 +00:00
|
|
|
const KEY: Option<&'static str> = Some("project_panel");
|
|
|
|
|
|
|
|
type FileContent = ProjectPanelSettingsContent;
|
|
|
|
|
|
|
|
fn load(
|
|
|
|
default_value: &Self::FileContent,
|
|
|
|
user_values: &[&Self::FileContent],
|
2024-01-03 18:47:33 +00:00
|
|
|
_: &mut gpui::AppContext,
|
2023-05-23 03:23:07 +00:00
|
|
|
) -> anyhow::Result<Self> {
|
|
|
|
Self::load_via_json_merge(default_value, user_values)
|
|
|
|
}
|
|
|
|
}
|