project_settings.rs

 1use collections::HashMap;
 2use schemars::JsonSchema;
 3use serde::{Deserialize, Serialize};
 4use settings::Setting;
 5use std::sync::Arc;
 6
 7#[derive(Clone, Serialize, Deserialize, JsonSchema)]
 8pub struct ProjectSettings {
 9    #[serde(default)]
10    pub lsp: HashMap<Arc<str>, LspSettings>,
11}
12
13#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
14#[serde(rename_all = "snake_case")]
15pub struct LspSettings {
16    pub initialization_options: Option<serde_json::Value>,
17}
18
19impl Setting for ProjectSettings {
20    const KEY: Option<&'static str> = None;
21
22    type FileContent = Self;
23
24    fn load(
25        default_value: &Self::FileContent,
26        user_values: &[&Self::FileContent],
27        _: &gpui::AppContext,
28    ) -> anyhow::Result<Self> {
29        Self::load_via_json_merge(default_value, user_values)
30    }
31}