2023-05-17 00:45:04 +00:00
|
|
|
use collections::HashMap;
|
|
|
|
use schemars::JsonSchema;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use settings::Setting;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
2023-05-20 00:15:05 +00:00
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
2023-05-17 00:45:04 +00:00
|
|
|
pub struct ProjectSettings {
|
|
|
|
#[serde(default)]
|
|
|
|
pub lsp: HashMap<Arc<str>, LspSettings>,
|
2023-05-25 18:29:28 +00:00
|
|
|
#[serde(default)]
|
|
|
|
pub git: GitSettings,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
|
|
|
pub struct GitSettings {
|
|
|
|
pub git_gutter: Option<GitGutterSetting>,
|
|
|
|
pub gutter_debounce: Option<u64>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
|
|
|
#[serde(rename_all = "snake_case")]
|
|
|
|
pub enum GitGutterSetting {
|
|
|
|
#[default]
|
|
|
|
TrackedFiles,
|
|
|
|
Hide,
|
2023-05-17 00:45:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
|
|
|
#[serde(rename_all = "snake_case")]
|
|
|
|
pub struct LspSettings {
|
|
|
|
pub initialization_options: Option<serde_json::Value>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Setting for ProjectSettings {
|
|
|
|
const KEY: Option<&'static str> = None;
|
|
|
|
|
|
|
|
type FileContent = Self;
|
|
|
|
|
|
|
|
fn load(
|
|
|
|
default_value: &Self::FileContent,
|
|
|
|
user_values: &[&Self::FileContent],
|
|
|
|
_: &gpui::AppContext,
|
|
|
|
) -> anyhow::Result<Self> {
|
|
|
|
Self::load_via_json_merge(default_value, user_values)
|
|
|
|
}
|
|
|
|
}
|