1use collections::HashMap;
2use gpui::AppContext;
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5use settings::Settings;
6use std::sync::Arc;
7
8#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
9pub struct ProjectSettings {
10 /// Configuration for language servers.
11 ///
12 /// The following settings can be overriden for specific language servers:
13 /// - initialization_options
14 /// To override settings for a language, add an entry for that language server's
15 /// name to the lsp value.
16 /// Default: null
17 #[serde(default)]
18 pub lsp: HashMap<Arc<str>, LspSettings>,
19
20 /// Configuration for Git-related features
21 #[serde(default)]
22 pub git: GitSettings,
23 /// Completely ignore files matching globs from `file_scan_exclusions`
24 ///
25 /// Default: [
26 /// "**/.git",
27 /// "**/.svn",
28 /// "**/.hg",
29 /// "**/CVS",
30 /// "**/.DS_Store",
31 /// "**/Thumbs.db",
32 /// "**/.classpath",
33 /// "**/.settings"
34 /// ]
35 #[serde(default)]
36 pub file_scan_exclusions: Option<Vec<String>>,
37}
38
39#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
40pub struct GitSettings {
41 /// Whether or not to show the git gutter.
42 ///
43 /// Default: tracked_files
44 pub git_gutter: Option<GitGutterSetting>,
45 pub gutter_debounce: Option<u64>,
46}
47
48#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema)]
49#[serde(rename_all = "snake_case")]
50pub enum GitGutterSetting {
51 /// Show git gutter in tracked files.
52 #[default]
53 TrackedFiles,
54 /// Hide git gutter
55 Hide,
56}
57
58#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
59#[serde(rename_all = "snake_case")]
60pub struct LspSettings {
61 pub initialization_options: Option<serde_json::Value>,
62}
63
64impl Settings for ProjectSettings {
65 const KEY: Option<&'static str> = None;
66
67 type FileContent = Self;
68
69 fn load(
70 default_value: &Self::FileContent,
71 user_values: &[&Self::FileContent],
72 _: &mut AppContext,
73 ) -> anyhow::Result<Self> {
74 Self::load_via_json_merge(default_value, user_values)
75 }
76}