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 overridden 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
24 /// Completely ignore files matching globs from `file_scan_exclusions`
25 ///
26 /// Default: [
27 /// "**/.git",
28 /// "**/.svn",
29 /// "**/.hg",
30 /// "**/CVS",
31 /// "**/.DS_Store",
32 /// "**/Thumbs.db",
33 /// "**/.classpath",
34 /// "**/.settings"
35 /// ]
36 #[serde(default)]
37 pub file_scan_exclusions: Option<Vec<String>>,
38
39 /// Treat the files matching these globs as `.env` files.
40 /// Default: [ "**/.env*" ]
41 pub private_files: Option<Vec<String>>,
42}
43
44#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
45pub struct GitSettings {
46 /// Whether or not to show the git gutter.
47 ///
48 /// Default: tracked_files
49 pub git_gutter: Option<GitGutterSetting>,
50 pub gutter_debounce: Option<u64>,
51}
52
53#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema)]
54#[serde(rename_all = "snake_case")]
55pub enum GitGutterSetting {
56 /// Show git gutter in tracked files.
57 #[default]
58 TrackedFiles,
59 /// Hide git gutter
60 Hide,
61}
62
63#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
64#[serde(rename_all = "snake_case")]
65pub struct LspSettings {
66 pub initialization_options: Option<serde_json::Value>,
67 pub settings: Option<serde_json::Value>,
68}
69
70impl Settings for ProjectSettings {
71 const KEY: Option<&'static str> = None;
72
73 type FileContent = Self;
74
75 fn load(
76 default_value: &Self::FileContent,
77 user_values: &[&Self::FileContent],
78 _: &mut AppContext,
79 ) -> anyhow::Result<Self> {
80 Self::load_via_json_merge(default_value, user_values)
81 }
82}