1mod agent;
2mod language;
3mod project;
4mod terminal;
5mod theme;
6mod workspace;
7pub use agent::*;
8pub use language::*;
9pub use project::*;
10pub use terminal::*;
11pub use theme::*;
12pub use workspace::*;
13
14use collections::HashMap;
15use gpui::{App, SharedString};
16use release_channel::ReleaseChannel;
17use schemars::JsonSchema;
18use serde::{Deserialize, Serialize};
19use std::env;
20use std::sync::Arc;
21pub use util::serde::default_true;
22
23use crate::ActiveSettingsProfileName;
24
25#[derive(Debug, PartialEq, Default, Clone, Serialize, Deserialize, JsonSchema)]
26pub struct SettingsContent {
27 #[serde(flatten)]
28 pub project: ProjectSettingsContent,
29
30 #[serde(flatten)]
31 pub theme: Box<ThemeSettingsContent>,
32
33 #[serde(flatten)]
34 pub extension: ExtensionSettingsContent,
35
36 #[serde(flatten)]
37 pub workspace: WorkspaceSettingsContent,
38
39 pub tabs: Option<ItemSettingsContent>,
40 pub tab_bar: Option<TabBarSettingsContent>,
41
42 pub preview_tabs: Option<PreviewTabsSettingsContent>,
43
44 pub agent: Option<AgentSettingsContent>,
45 pub agent_servers: Option<AllAgentServersSettings>,
46
47 /// Configuration of audio in Zed.
48 pub audio: Option<AudioSettingsContent>,
49 pub auto_update: Option<bool>,
50
51 // todo!() comments?!
52 pub base_keymap: Option<BaseKeymapContent>,
53
54 pub debugger: Option<DebuggerSettingsContent>,
55
56 /// Configuration for Diagnostics-related features.
57 pub diagnostics: Option<DiagnosticsSettingsContent>,
58
59 /// Configuration for Git-related features
60 pub git: Option<GitSettings>,
61
62 /// Common language server settings.
63 pub global_lsp_settings: Option<GlobalLspSettingsContent>,
64
65 /// Whether or not to enable Helix mode.
66 ///
67 /// Default: false
68 pub helix_mode: Option<bool>,
69 /// A map of log scopes to the desired log level.
70 /// Useful for filtering out noisy logs or enabling more verbose logging.
71 ///
72 /// Example: {"log": {"client": "warn"}}
73 pub log: Option<HashMap<String, String>>,
74
75 /// Configuration for Node-related features
76 pub node: Option<NodeBinarySettings>,
77
78 pub proxy: Option<String>,
79
80 /// The URL of the Zed server to connect to.
81 pub server_url: Option<String>,
82
83 /// Configuration for session-related features
84 pub session: Option<SessionSettingsContent>,
85 /// Control what info is collected by Zed.
86 pub telemetry: Option<TelemetrySettingsContent>,
87
88 /// Configuration of the terminal in Zed.
89 pub terminal: Option<TerminalSettingsContent>,
90
91 pub title_bar: Option<TitleBarSettingsContent>,
92
93 /// Whether or not to enable Vim mode.
94 ///
95 /// Default: false
96 pub vim_mode: Option<bool>,
97
98 // Settings related to calls in Zed
99 pub calls: Option<CallSettingsContent>,
100
101 /// Whether to disable all AI features in Zed.
102 ///
103 /// Default: false
104 pub disable_ai: Option<bool>,
105}
106
107impl SettingsContent {
108 pub fn languages_mut(&mut self) -> &mut HashMap<SharedString, LanguageSettingsContent> {
109 &mut self.project.all_languages.languages.0
110 }
111}
112
113// todo!() what should this be?
114#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
115pub struct ServerSettingsContent {
116 #[serde(flatten)]
117 pub project: ProjectSettingsContent,
118}
119
120#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema)]
121pub struct UserSettingsContent {
122 #[serde(flatten)]
123 pub content: Box<SettingsContent>,
124
125 pub dev: Option<Box<SettingsContent>>,
126 pub nightly: Option<Box<SettingsContent>>,
127 pub preview: Option<Box<SettingsContent>>,
128 pub stable: Option<Box<SettingsContent>>,
129
130 pub macos: Option<Box<SettingsContent>>,
131 pub windows: Option<Box<SettingsContent>>,
132 pub linux: Option<Box<SettingsContent>>,
133
134 #[serde(default)]
135 pub profiles: HashMap<String, SettingsContent>,
136}
137
138pub struct ExtensionsSettingsContent {
139 pub all_languages: AllLanguageSettingsContent,
140}
141
142impl UserSettingsContent {
143 pub fn for_release_channel(&self) -> Option<&SettingsContent> {
144 match *release_channel::RELEASE_CHANNEL {
145 ReleaseChannel::Dev => self.dev.as_deref(),
146 ReleaseChannel::Nightly => self.nightly.as_deref(),
147 ReleaseChannel::Preview => self.preview.as_deref(),
148 ReleaseChannel::Stable => self.stable.as_deref(),
149 }
150 }
151
152 pub fn for_os(&self) -> Option<&SettingsContent> {
153 match env::consts::OS {
154 "macos" => self.macos.as_deref(),
155 "linux" => self.linux.as_deref(),
156 "windows" => self.windows.as_deref(),
157 _ => None,
158 }
159 }
160
161 pub fn for_profile(&self, cx: &App) -> Option<&SettingsContent> {
162 let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() else {
163 return None;
164 };
165 self.profiles.get(&active_profile.0)
166 }
167}
168
169/// Base key bindings scheme. Base keymaps can be overridden with user keymaps.
170///
171/// Default: VSCode
172#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)]
173pub enum BaseKeymapContent {
174 #[default]
175 VSCode,
176 JetBrains,
177 SublimeText,
178 Atom,
179 TextMate,
180 Emacs,
181 Cursor,
182 None,
183}
184
185#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
186pub struct TitleBarSettingsContent {
187 /// Controls when the title bar is visible: "always" | "never" | "hide_in_full_screen".
188 ///
189 /// Default: "always"
190 pub show: Option<TitleBarVisibilityContent>,
191 /// Whether to show the branch icon beside branch switcher in the title bar.
192 ///
193 /// Default: false
194 pub show_branch_icon: Option<bool>,
195 /// Whether to show onboarding banners in the title bar.
196 ///
197 /// Default: true
198 pub show_onboarding_banner: Option<bool>,
199 /// Whether to show user avatar in the title bar.
200 ///
201 /// Default: true
202 pub show_user_picture: Option<bool>,
203 /// Whether to show the branch name button in the titlebar.
204 ///
205 /// Default: true
206 pub show_branch_name: Option<bool>,
207 /// Whether to show the project host and name in the titlebar.
208 ///
209 /// Default: true
210 pub show_project_items: Option<bool>,
211 /// Whether to show the sign in button in the title bar.
212 ///
213 /// Default: true
214 pub show_sign_in: Option<bool>,
215 /// Whether to show the menus in the title bar.
216 ///
217 /// Default: false
218 pub show_menus: Option<bool>,
219}
220
221#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Debug)]
222#[serde(rename_all = "snake_case")]
223pub enum TitleBarVisibilityContent {
224 Always,
225 Never,
226 HideInFullScreen,
227}
228
229/// Configuration of audio in Zed.
230#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
231pub struct AudioSettingsContent {
232 /// Opt into the new audio system.
233 #[serde(rename = "experimental.rodio_audio", default)]
234 pub rodio_audio: Option<bool>,
235 /// Requires 'rodio_audio: true'
236 ///
237 /// Use the new audio systems automatic gain control for your microphone.
238 /// This affects how loud you sound to others.
239 #[serde(rename = "experimental.control_input_volume", default)]
240 pub control_input_volume: Option<bool>,
241 /// Requires 'rodio_audio: true'
242 ///
243 /// Use the new audio systems automatic gain control on everyone in the
244 /// call. This makes call members who are too quite louder and those who are
245 /// too loud quieter. This only affects how things sound for you.
246 #[serde(rename = "experimental.control_output_volume", default)]
247 pub control_output_volume: Option<bool>,
248}
249
250/// Control what info is collected by Zed.
251#[derive(Default, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Debug)]
252pub struct TelemetrySettingsContent {
253 /// Send debug info like crash reports.
254 ///
255 /// Default: true
256 pub diagnostics: Option<bool>,
257 /// Send anonymized usage data like what languages you're using Zed with.
258 ///
259 /// Default: true
260 pub metrics: Option<bool>,
261}
262
263#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Clone)]
264pub struct DebuggerSettingsContent {
265 /// Determines the stepping granularity.
266 ///
267 /// Default: line
268 pub stepping_granularity: Option<SteppingGranularity>,
269 /// Whether the breakpoints should be reused across Zed sessions.
270 ///
271 /// Default: true
272 pub save_breakpoints: Option<bool>,
273 /// Whether to show the debug button in the status bar.
274 ///
275 /// Default: true
276 pub button: Option<bool>,
277 /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
278 ///
279 /// Default: 2000ms
280 pub timeout: Option<u64>,
281 /// Whether to log messages between active debug adapters and Zed
282 ///
283 /// Default: true
284 pub log_dap_communications: Option<bool>,
285 /// Whether to format dap messages in when adding them to debug adapter logger
286 ///
287 /// Default: true
288 pub format_dap_log_messages: Option<bool>,
289 /// The dock position of the debug panel
290 ///
291 /// Default: Bottom
292 pub dock: Option<DockPosition>,
293}
294
295/// The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
296#[derive(PartialEq, Eq, Debug, Hash, Clone, Copy, Deserialize, Serialize, JsonSchema)]
297#[serde(rename_all = "snake_case")]
298pub enum SteppingGranularity {
299 /// The step should allow the program to run until the current statement has finished executing.
300 /// The meaning of a statement is determined by the adapter and it may be considered equivalent to a line.
301 /// For example 'for(int i = 0; i < 10; i++)' could be considered to have 3 statements 'int i = 0', 'i < 10', and 'i++'.
302 Statement,
303 /// The step should allow the program to run until the current source line has executed.
304 Line,
305 /// The step should allow one instruction to execute (e.g. one x86 instruction).
306 Instruction,
307}
308
309#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
310#[serde(rename_all = "snake_case")]
311pub enum DockPosition {
312 Left,
313 Bottom,
314 Right,
315}
316
317/// Settings for slash commands.
318#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, PartialEq, Eq)]
319pub struct SlashCommandSettings {
320 /// Settings for the `/cargo-workspace` slash command.
321 pub cargo_workspace: Option<CargoWorkspaceCommandSettings>,
322}
323
324/// Settings for the `/cargo-workspace` slash command.
325#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, PartialEq, Eq)]
326pub struct CargoWorkspaceCommandSettings {
327 /// Whether `/cargo-workspace` is enabled.
328 pub enabled: Option<bool>,
329}
330
331/// Configuration of voice calls in Zed.
332#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
333pub struct CallSettingsContent {
334 /// Whether the microphone should be muted when joining a channel or a call.
335 ///
336 /// Default: false
337 pub mute_on_join: Option<bool>,
338
339 /// Whether your current project should be shared when joining an empty channel.
340 ///
341 /// Default: false
342 pub share_on_join: Option<bool>,
343}
344
345#[derive(Deserialize, Serialize, PartialEq, Debug, Default, Clone, JsonSchema)]
346pub struct ExtensionSettingsContent {
347 /// The extensions that should be automatically installed by Zed.
348 ///
349 /// This is used to make functionality provided by extensions (e.g., language support)
350 /// available out-of-the-box.
351 ///
352 /// Default: { "html": true }
353 #[serde(default)]
354 pub auto_install_extensions: HashMap<Arc<str>, bool>,
355 #[serde(default)]
356 pub auto_update_extensions: HashMap<Arc<str>, bool>,
357}