settings_content.rs

  1mod agent;
  2mod editor;
  3mod language;
  4mod project;
  5mod terminal;
  6mod theme;
  7mod workspace;
  8pub use agent::*;
  9pub use editor::*;
 10pub use language::*;
 11pub use project::*;
 12pub use terminal::*;
 13pub use theme::*;
 14pub use workspace::*;
 15
 16use collections::HashMap;
 17use gpui::{App, SharedString};
 18use release_channel::ReleaseChannel;
 19use schemars::JsonSchema;
 20use serde::{Deserialize, Serialize};
 21use std::env;
 22use std::sync::Arc;
 23pub use util::serde::default_true;
 24
 25use crate::ActiveSettingsProfileName;
 26
 27#[derive(Debug, PartialEq, Default, Clone, Serialize, Deserialize, JsonSchema)]
 28pub struct SettingsContent {
 29    #[serde(flatten)]
 30    pub project: ProjectSettingsContent,
 31
 32    #[serde(flatten)]
 33    pub theme: Box<ThemeSettingsContent>,
 34
 35    #[serde(flatten)]
 36    pub extension: ExtensionSettingsContent,
 37
 38    #[serde(flatten)]
 39    pub workspace: WorkspaceSettingsContent,
 40
 41    #[serde(flatten)]
 42    pub editor: EditorSettingsContent,
 43
 44    pub git_panel: Option<GitPanelSettingsContent>,
 45
 46    pub tabs: Option<ItemSettingsContent>,
 47    pub tab_bar: Option<TabBarSettingsContent>,
 48
 49    pub preview_tabs: Option<PreviewTabsSettingsContent>,
 50
 51    pub agent: Option<AgentSettingsContent>,
 52    pub agent_servers: Option<AllAgentServersSettings>,
 53
 54    /// Configuration of audio in Zed.
 55    pub audio: Option<AudioSettingsContent>,
 56
 57    /// Whether or not to automatically check for updates.
 58    ///
 59    /// Default: true
 60    pub auto_update: Option<bool>,
 61
 62    // todo!() comments?!
 63    pub base_keymap: Option<BaseKeymapContent>,
 64
 65    /// Configuration for the collab panel visual settings.
 66    pub collaboration_panel: Option<PanelSettingsContent>,
 67
 68    pub debugger: Option<DebuggerSettingsContent>,
 69
 70    /// Configuration for Diagnostics-related features.
 71    pub diagnostics: Option<DiagnosticsSettingsContent>,
 72
 73    /// Configuration for Git-related features
 74    pub git: Option<GitSettings>,
 75
 76    /// Common language server settings.
 77    pub global_lsp_settings: Option<GlobalLspSettingsContent>,
 78
 79    /// Whether or not to enable Helix mode.
 80    ///
 81    /// Default: false
 82    pub helix_mode: Option<bool>,
 83
 84    /// A map of log scopes to the desired log level.
 85    /// Useful for filtering out noisy logs or enabling more verbose logging.
 86    ///
 87    /// Example: {"log": {"client": "warn"}}
 88    pub log: Option<HashMap<String, String>>,
 89
 90    /// Configuration for the Message Editor
 91    pub message_editor: Option<MessageEditorSettings>,
 92
 93    /// Configuration for Node-related features
 94    pub node: Option<NodeBinarySettings>,
 95
 96    /// Configuration for the Notification Panel
 97    pub notification_panel: Option<NotificationPanelSettingsContent>,
 98
 99    pub proxy: Option<String>,
100
101    /// The URL of the Zed server to connect to.
102    pub server_url: Option<String>,
103
104    /// Configuration for session-related features
105    pub session: Option<SessionSettingsContent>,
106    /// Control what info is collected by Zed.
107    pub telemetry: Option<TelemetrySettingsContent>,
108
109    /// Configuration of the terminal in Zed.
110    pub terminal: Option<TerminalSettingsContent>,
111
112    pub title_bar: Option<TitleBarSettingsContent>,
113
114    /// Whether or not to enable Vim mode.
115    ///
116    /// Default: false
117    pub vim_mode: Option<bool>,
118
119    // Settings related to calls in Zed
120    pub calls: Option<CallSettingsContent>,
121
122    /// Whether to disable all AI features in Zed.
123    ///
124    /// Default: false
125    pub disable_ai: Option<bool>,
126}
127
128impl SettingsContent {
129    pub fn languages_mut(&mut self) -> &mut HashMap<SharedString, LanguageSettingsContent> {
130        &mut self.project.all_languages.languages.0
131    }
132}
133
134// todo!() what should this be?
135#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
136pub struct ServerSettingsContent {
137    #[serde(flatten)]
138    pub project: ProjectSettingsContent,
139}
140
141#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema)]
142pub struct UserSettingsContent {
143    #[serde(flatten)]
144    pub content: Box<SettingsContent>,
145
146    pub dev: Option<Box<SettingsContent>>,
147    pub nightly: Option<Box<SettingsContent>>,
148    pub preview: Option<Box<SettingsContent>>,
149    pub stable: Option<Box<SettingsContent>>,
150
151    pub macos: Option<Box<SettingsContent>>,
152    pub windows: Option<Box<SettingsContent>>,
153    pub linux: Option<Box<SettingsContent>>,
154
155    #[serde(default)]
156    pub profiles: HashMap<String, SettingsContent>,
157}
158
159pub struct ExtensionsSettingsContent {
160    pub all_languages: AllLanguageSettingsContent,
161}
162
163impl UserSettingsContent {
164    pub fn for_release_channel(&self) -> Option<&SettingsContent> {
165        match *release_channel::RELEASE_CHANNEL {
166            ReleaseChannel::Dev => self.dev.as_deref(),
167            ReleaseChannel::Nightly => self.nightly.as_deref(),
168            ReleaseChannel::Preview => self.preview.as_deref(),
169            ReleaseChannel::Stable => self.stable.as_deref(),
170        }
171    }
172
173    pub fn for_os(&self) -> Option<&SettingsContent> {
174        match env::consts::OS {
175            "macos" => self.macos.as_deref(),
176            "linux" => self.linux.as_deref(),
177            "windows" => self.windows.as_deref(),
178            _ => None,
179        }
180    }
181
182    pub fn for_profile(&self, cx: &App) -> Option<&SettingsContent> {
183        let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() else {
184            return None;
185        };
186        self.profiles.get(&active_profile.0)
187    }
188}
189
190/// Base key bindings scheme. Base keymaps can be overridden with user keymaps.
191///
192/// Default: VSCode
193#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)]
194pub enum BaseKeymapContent {
195    #[default]
196    VSCode,
197    JetBrains,
198    SublimeText,
199    Atom,
200    TextMate,
201    Emacs,
202    Cursor,
203    None,
204}
205
206#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
207pub struct TitleBarSettingsContent {
208    /// Controls when the title bar is visible: "always" | "never" | "hide_in_full_screen".
209    ///
210    /// Default: "always"
211    pub show: Option<TitleBarVisibility>,
212    /// Whether to show the branch icon beside branch switcher in the title bar.
213    ///
214    /// Default: false
215    pub show_branch_icon: Option<bool>,
216    /// Whether to show onboarding banners in the title bar.
217    ///
218    /// Default: true
219    pub show_onboarding_banner: Option<bool>,
220    /// Whether to show user avatar in the title bar.
221    ///
222    /// Default: true
223    pub show_user_picture: Option<bool>,
224    /// Whether to show the branch name button in the titlebar.
225    ///
226    /// Default: true
227    pub show_branch_name: Option<bool>,
228    /// Whether to show the project host and name in the titlebar.
229    ///
230    /// Default: true
231    pub show_project_items: Option<bool>,
232    /// Whether to show the sign in button in the title bar.
233    ///
234    /// Default: true
235    pub show_sign_in: Option<bool>,
236    /// Whether to show the menus in the title bar.
237    ///
238    /// Default: false
239    pub show_menus: Option<bool>,
240}
241
242#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Debug)]
243#[serde(rename_all = "snake_case")]
244pub enum TitleBarVisibility {
245    Always,
246    Never,
247    HideInFullScreen,
248}
249
250/// Configuration of audio in Zed.
251#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
252pub struct AudioSettingsContent {
253    /// Opt into the new audio system.
254    #[serde(rename = "experimental.rodio_audio", default)]
255    pub rodio_audio: Option<bool>,
256    /// Requires 'rodio_audio: true'
257    ///
258    /// Use the new audio systems automatic gain control for your microphone.
259    /// This affects how loud you sound to others.
260    #[serde(rename = "experimental.control_input_volume", default)]
261    pub control_input_volume: Option<bool>,
262    /// Requires 'rodio_audio: true'
263    ///
264    /// Use the new audio systems automatic gain control on everyone in the
265    /// call. This makes call members who are too quite louder and those who are
266    /// too loud quieter. This only affects how things sound for you.
267    #[serde(rename = "experimental.control_output_volume", default)]
268    pub control_output_volume: Option<bool>,
269}
270
271/// Control what info is collected by Zed.
272#[derive(Default, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Debug)]
273pub struct TelemetrySettingsContent {
274    /// Send debug info like crash reports.
275    ///
276    /// Default: true
277    pub diagnostics: Option<bool>,
278    /// Send anonymized usage data like what languages you're using Zed with.
279    ///
280    /// Default: true
281    pub metrics: Option<bool>,
282}
283
284#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Clone)]
285pub struct DebuggerSettingsContent {
286    /// Determines the stepping granularity.
287    ///
288    /// Default: line
289    pub stepping_granularity: Option<SteppingGranularity>,
290    /// Whether the breakpoints should be reused across Zed sessions.
291    ///
292    /// Default: true
293    pub save_breakpoints: Option<bool>,
294    /// Whether to show the debug button in the status bar.
295    ///
296    /// Default: true
297    pub button: Option<bool>,
298    /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
299    ///
300    /// Default: 2000ms
301    pub timeout: Option<u64>,
302    /// Whether to log messages between active debug adapters and Zed
303    ///
304    /// Default: true
305    pub log_dap_communications: Option<bool>,
306    /// Whether to format dap messages in when adding them to debug adapter logger
307    ///
308    /// Default: true
309    pub format_dap_log_messages: Option<bool>,
310    /// The dock position of the debug panel
311    ///
312    /// Default: Bottom
313    pub dock: Option<DockPosition>,
314}
315
316/// The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
317#[derive(PartialEq, Eq, Debug, Hash, Clone, Copy, Deserialize, Serialize, JsonSchema)]
318#[serde(rename_all = "snake_case")]
319pub enum SteppingGranularity {
320    /// The step should allow the program to run until the current statement has finished executing.
321    /// The meaning of a statement is determined by the adapter and it may be considered equivalent to a line.
322    /// For example 'for(int i = 0; i < 10; i++)' could be considered to have 3 statements 'int i = 0', 'i < 10', and 'i++'.
323    Statement,
324    /// The step should allow the program to run until the current source line has executed.
325    Line,
326    /// The step should allow one instruction to execute (e.g. one x86 instruction).
327    Instruction,
328}
329
330#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
331#[serde(rename_all = "snake_case")]
332pub enum DockPosition {
333    Left,
334    Bottom,
335    Right,
336}
337
338/// Settings for slash commands.
339#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, PartialEq, Eq)]
340pub struct SlashCommandSettings {
341    /// Settings for the `/cargo-workspace` slash command.
342    pub cargo_workspace: Option<CargoWorkspaceCommandSettings>,
343}
344
345/// Settings for the `/cargo-workspace` slash command.
346#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, PartialEq, Eq)]
347pub struct CargoWorkspaceCommandSettings {
348    /// Whether `/cargo-workspace` is enabled.
349    pub enabled: Option<bool>,
350}
351
352/// Configuration of voice calls in Zed.
353#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
354pub struct CallSettingsContent {
355    /// Whether the microphone should be muted when joining a channel or a call.
356    ///
357    /// Default: false
358    pub mute_on_join: Option<bool>,
359
360    /// Whether your current project should be shared when joining an empty channel.
361    ///
362    /// Default: false
363    pub share_on_join: Option<bool>,
364}
365
366#[derive(Deserialize, Serialize, PartialEq, Debug, Default, Clone, JsonSchema)]
367pub struct ExtensionSettingsContent {
368    /// The extensions that should be automatically installed by Zed.
369    ///
370    /// This is used to make functionality provided by extensions (e.g., language support)
371    /// available out-of-the-box.
372    ///
373    /// Default: { "html": true }
374    #[serde(default)]
375    pub auto_install_extensions: HashMap<Arc<str>, bool>,
376    #[serde(default)]
377    pub auto_update_extensions: HashMap<Arc<str>, bool>,
378}
379
380#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
381pub struct GitPanelSettingsContent {
382    /// Whether to show the panel button in the status bar.
383    ///
384    /// Default: true
385    pub button: Option<bool>,
386    /// Where to dock the panel.
387    ///
388    /// Default: left
389    pub dock: Option<DockPosition>,
390    /// Default width of the panel in pixels.
391    ///
392    /// Default: 360
393    pub default_width: Option<f32>,
394    /// How entry statuses are displayed.
395    ///
396    /// Default: icon
397    pub status_style: Option<StatusStyle>,
398    /// How and when the scrollbar should be displayed.
399    ///
400    /// Default: inherits editor scrollbar settings
401    pub scrollbar: Option<ScrollbarSettings>,
402
403    /// What the default branch name should be when
404    /// `init.defaultBranch` is not set in git
405    ///
406    /// Default: main
407    pub fallback_branch_name: Option<String>,
408
409    /// Whether to sort entries in the panel by path
410    /// or by status (the default).
411    ///
412    /// Default: false
413    pub sort_by_path: Option<bool>,
414
415    /// Whether to collapse untracked files in the diff panel.
416    ///
417    /// Default: false
418    pub collapse_untracked_diff: Option<bool>,
419}
420
421#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
422#[serde(rename_all = "snake_case")]
423pub enum StatusStyle {
424    #[default]
425    Icon,
426    LabelColor,
427}
428
429#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
430pub struct ScrollbarSettings {
431    pub show: Option<ShowScrollbar>,
432}
433
434#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, PartialEq)]
435pub struct NotificationPanelSettingsContent {
436    /// Whether to show the panel button in the status bar.
437    ///
438    /// Default: true
439    pub button: Option<bool>,
440    /// Where to dock the panel.
441    ///
442    /// Default: right
443    pub dock: Option<DockPosition>,
444    /// Default width of the panel in pixels.
445    ///
446    /// Default: 300
447    pub default_width: Option<f32>,
448}
449
450#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, PartialEq)]
451pub struct PanelSettingsContent {
452    /// Whether to show the panel button in the status bar.
453    ///
454    /// Default: true
455    pub button: Option<bool>,
456    /// Where to dock the panel.
457    ///
458    /// Default: left
459    pub dock: Option<DockPosition>,
460    /// Default width of the panel in pixels.
461    ///
462    /// Default: 240
463    pub default_width: Option<f32>,
464}
465
466#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, PartialEq)]
467pub struct MessageEditorSettings {
468    /// Whether to automatically replace emoji shortcodes with emoji characters.
469    /// For example: typing `:wave:` gets replaced with `👋`.
470    ///
471    /// Default: false
472    pub auto_replace_emoji_shortcode: Option<bool>,
473}
474
475#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
476pub struct FileFinderSettingsContent {
477    /// Whether to show file icons in the file finder.
478    ///
479    /// Default: true
480    pub file_icons: Option<bool>,
481    /// Determines how much space the file finder can take up in relation to the available window width.
482    ///
483    /// Default: small
484    pub modal_max_width: Option<FileFinderWidth>,
485    /// Determines whether the file finder should skip focus for the active file in search results.
486    ///
487    /// Default: true
488    pub skip_focus_for_active_in_search: Option<bool>,
489    /// Determines whether to show the git status in the file finder
490    ///
491    /// Default: true
492    pub git_status: Option<bool>,
493    /// Whether to use gitignored files when searching.
494    /// Only the file Zed had indexed will be used, not necessary all the gitignored files.
495    ///
496    /// Can accept 3 values:
497    /// * `Some(true)`: Use all gitignored files
498    /// * `Some(false)`: Use only the files Zed had indexed
499    /// * `None`: Be smart and search for ignored when called from a gitignored worktree
500    ///
501    /// Default: None
502    pub include_ignored: Option<Option<bool>>,
503}