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    /// Settings related to the file finder.
 45    pub file_finder: Option<FileFinderSettingsContent>,
 46
 47    pub git_panel: Option<GitPanelSettingsContent>,
 48
 49    pub tabs: Option<ItemSettingsContent>,
 50    pub tab_bar: Option<TabBarSettingsContent>,
 51
 52    pub preview_tabs: Option<PreviewTabsSettingsContent>,
 53
 54    pub agent: Option<AgentSettingsContent>,
 55    pub agent_servers: Option<AllAgentServersSettings>,
 56
 57    /// Configuration of audio in Zed.
 58    pub audio: Option<AudioSettingsContent>,
 59
 60    /// Whether or not to automatically check for updates.
 61    ///
 62    /// Default: true
 63    pub auto_update: Option<bool>,
 64
 65    // todo!() comments?!
 66    pub base_keymap: Option<BaseKeymapContent>,
 67
 68    /// Configuration for the collab panel visual settings.
 69    pub collaboration_panel: Option<PanelSettingsContent>,
 70
 71    pub debugger: Option<DebuggerSettingsContent>,
 72
 73    /// Configuration for Diagnostics-related features.
 74    pub diagnostics: Option<DiagnosticsSettingsContent>,
 75
 76    /// Configuration for Git-related features
 77    pub git: Option<GitSettings>,
 78
 79    /// Common language server settings.
 80    pub global_lsp_settings: Option<GlobalLspSettingsContent>,
 81
 82    /// Whether or not to enable Helix mode.
 83    ///
 84    /// Default: false
 85    pub helix_mode: Option<bool>,
 86
 87    pub journal: Option<JournalSettingsContent>,
 88
 89    /// A map of log scopes to the desired log level.
 90    /// Useful for filtering out noisy logs or enabling more verbose logging.
 91    ///
 92    /// Example: {"log": {"client": "warn"}}
 93    pub log: Option<HashMap<String, String>>,
 94
 95    pub line_indicator_format: Option<LineIndicatorFormat>,
 96
 97    pub outline_panel: Option<OutlinePanelSettingsContent>,
 98
 99    /// Configuration for the Message Editor
100    pub message_editor: Option<MessageEditorSettings>,
101
102    /// Configuration for Node-related features
103    pub node: Option<NodeBinarySettings>,
104
105    /// Configuration for the Notification Panel
106    pub notification_panel: Option<NotificationPanelSettingsContent>,
107
108    pub proxy: Option<String>,
109
110    /// The URL of the Zed server to connect to.
111    pub server_url: Option<String>,
112
113    /// Configuration for session-related features
114    pub session: Option<SessionSettingsContent>,
115    /// Control what info is collected by Zed.
116    pub telemetry: Option<TelemetrySettingsContent>,
117
118    /// Configuration of the terminal in Zed.
119    pub terminal: Option<TerminalSettingsContent>,
120
121    pub title_bar: Option<TitleBarSettingsContent>,
122
123    /// Whether or not to enable Vim mode.
124    ///
125    /// Default: false
126    pub vim_mode: Option<bool>,
127
128    // Settings related to calls in Zed
129    pub calls: Option<CallSettingsContent>,
130
131    /// Whether to disable all AI features in Zed.
132    ///
133    /// Default: false
134    pub disable_ai: Option<bool>,
135
136    /// Settings related to Vim mode in Zed.
137    pub vim: Option<VimSettingsContent>,
138}
139
140impl SettingsContent {
141    pub fn languages_mut(&mut self) -> &mut HashMap<SharedString, LanguageSettingsContent> {
142        &mut self.project.all_languages.languages.0
143    }
144}
145
146// todo!() what should this be?
147#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
148pub struct ServerSettingsContent {
149    #[serde(flatten)]
150    pub project: ProjectSettingsContent,
151}
152
153#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema)]
154pub struct UserSettingsContent {
155    #[serde(flatten)]
156    pub content: Box<SettingsContent>,
157
158    pub dev: Option<Box<SettingsContent>>,
159    pub nightly: Option<Box<SettingsContent>>,
160    pub preview: Option<Box<SettingsContent>>,
161    pub stable: Option<Box<SettingsContent>>,
162
163    pub macos: Option<Box<SettingsContent>>,
164    pub windows: Option<Box<SettingsContent>>,
165    pub linux: Option<Box<SettingsContent>>,
166
167    #[serde(default)]
168    pub profiles: HashMap<String, SettingsContent>,
169}
170
171pub struct ExtensionsSettingsContent {
172    pub all_languages: AllLanguageSettingsContent,
173}
174
175impl UserSettingsContent {
176    pub fn for_release_channel(&self) -> Option<&SettingsContent> {
177        match *release_channel::RELEASE_CHANNEL {
178            ReleaseChannel::Dev => self.dev.as_deref(),
179            ReleaseChannel::Nightly => self.nightly.as_deref(),
180            ReleaseChannel::Preview => self.preview.as_deref(),
181            ReleaseChannel::Stable => self.stable.as_deref(),
182        }
183    }
184
185    pub fn for_os(&self) -> Option<&SettingsContent> {
186        match env::consts::OS {
187            "macos" => self.macos.as_deref(),
188            "linux" => self.linux.as_deref(),
189            "windows" => self.windows.as_deref(),
190            _ => None,
191        }
192    }
193
194    pub fn for_profile(&self, cx: &App) -> Option<&SettingsContent> {
195        let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() else {
196            return None;
197        };
198        self.profiles.get(&active_profile.0)
199    }
200}
201
202/// Base key bindings scheme. Base keymaps can be overridden with user keymaps.
203///
204/// Default: VSCode
205#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)]
206pub enum BaseKeymapContent {
207    #[default]
208    VSCode,
209    JetBrains,
210    SublimeText,
211    Atom,
212    TextMate,
213    Emacs,
214    Cursor,
215    None,
216}
217
218#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
219pub struct TitleBarSettingsContent {
220    /// Controls when the title bar is visible: "always" | "never" | "hide_in_full_screen".
221    ///
222    /// Default: "always"
223    pub show: Option<TitleBarVisibility>,
224    /// Whether to show the branch icon beside branch switcher in the title bar.
225    ///
226    /// Default: false
227    pub show_branch_icon: Option<bool>,
228    /// Whether to show onboarding banners in the title bar.
229    ///
230    /// Default: true
231    pub show_onboarding_banner: Option<bool>,
232    /// Whether to show user avatar in the title bar.
233    ///
234    /// Default: true
235    pub show_user_picture: Option<bool>,
236    /// Whether to show the branch name button in the titlebar.
237    ///
238    /// Default: true
239    pub show_branch_name: Option<bool>,
240    /// Whether to show the project host and name in the titlebar.
241    ///
242    /// Default: true
243    pub show_project_items: Option<bool>,
244    /// Whether to show the sign in button in the title bar.
245    ///
246    /// Default: true
247    pub show_sign_in: Option<bool>,
248    /// Whether to show the menus in the title bar.
249    ///
250    /// Default: false
251    pub show_menus: Option<bool>,
252}
253
254#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Debug)]
255#[serde(rename_all = "snake_case")]
256pub enum TitleBarVisibility {
257    Always,
258    Never,
259    HideInFullScreen,
260}
261
262/// Configuration of audio in Zed.
263#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
264pub struct AudioSettingsContent {
265    /// Opt into the new audio system.
266    #[serde(rename = "experimental.rodio_audio", default)]
267    pub rodio_audio: Option<bool>,
268    /// Requires 'rodio_audio: true'
269    ///
270    /// Use the new audio systems automatic gain control for your microphone.
271    /// This affects how loud you sound to others.
272    #[serde(rename = "experimental.control_input_volume", default)]
273    pub control_input_volume: Option<bool>,
274    /// Requires 'rodio_audio: true'
275    ///
276    /// Use the new audio systems automatic gain control on everyone in the
277    /// call. This makes call members who are too quite louder and those who are
278    /// too loud quieter. This only affects how things sound for you.
279    #[serde(rename = "experimental.control_output_volume", default)]
280    pub control_output_volume: Option<bool>,
281}
282
283/// Control what info is collected by Zed.
284#[derive(Default, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Debug)]
285pub struct TelemetrySettingsContent {
286    /// Send debug info like crash reports.
287    ///
288    /// Default: true
289    pub diagnostics: Option<bool>,
290    /// Send anonymized usage data like what languages you're using Zed with.
291    ///
292    /// Default: true
293    pub metrics: Option<bool>,
294}
295
296#[derive(Default, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Clone)]
297pub struct DebuggerSettingsContent {
298    /// Determines the stepping granularity.
299    ///
300    /// Default: line
301    pub stepping_granularity: Option<SteppingGranularity>,
302    /// Whether the breakpoints should be reused across Zed sessions.
303    ///
304    /// Default: true
305    pub save_breakpoints: Option<bool>,
306    /// Whether to show the debug button in the status bar.
307    ///
308    /// Default: true
309    pub button: Option<bool>,
310    /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
311    ///
312    /// Default: 2000ms
313    pub timeout: Option<u64>,
314    /// Whether to log messages between active debug adapters and Zed
315    ///
316    /// Default: true
317    pub log_dap_communications: Option<bool>,
318    /// Whether to format dap messages in when adding them to debug adapter logger
319    ///
320    /// Default: true
321    pub format_dap_log_messages: Option<bool>,
322    /// The dock position of the debug panel
323    ///
324    /// Default: Bottom
325    pub dock: Option<DockPosition>,
326}
327
328/// The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
329#[derive(PartialEq, Eq, Debug, Hash, Clone, Copy, Deserialize, Serialize, JsonSchema)]
330#[serde(rename_all = "snake_case")]
331pub enum SteppingGranularity {
332    /// The step should allow the program to run until the current statement has finished executing.
333    /// The meaning of a statement is determined by the adapter and it may be considered equivalent to a line.
334    /// For example 'for(int i = 0; i < 10; i++)' could be considered to have 3 statements 'int i = 0', 'i < 10', and 'i++'.
335    Statement,
336    /// The step should allow the program to run until the current source line has executed.
337    Line,
338    /// The step should allow one instruction to execute (e.g. one x86 instruction).
339    Instruction,
340}
341
342#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
343#[serde(rename_all = "snake_case")]
344pub enum DockPosition {
345    Left,
346    Bottom,
347    Right,
348}
349
350/// Settings for slash commands.
351#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, PartialEq, Eq)]
352pub struct SlashCommandSettings {
353    /// Settings for the `/cargo-workspace` slash command.
354    pub cargo_workspace: Option<CargoWorkspaceCommandSettings>,
355}
356
357/// Settings for the `/cargo-workspace` slash command.
358#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, PartialEq, Eq)]
359pub struct CargoWorkspaceCommandSettings {
360    /// Whether `/cargo-workspace` is enabled.
361    pub enabled: Option<bool>,
362}
363
364/// Configuration of voice calls in Zed.
365#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
366pub struct CallSettingsContent {
367    /// Whether the microphone should be muted when joining a channel or a call.
368    ///
369    /// Default: false
370    pub mute_on_join: Option<bool>,
371
372    /// Whether your current project should be shared when joining an empty channel.
373    ///
374    /// Default: false
375    pub share_on_join: Option<bool>,
376}
377
378#[derive(Deserialize, Serialize, PartialEq, Debug, Default, Clone, JsonSchema)]
379pub struct ExtensionSettingsContent {
380    /// The extensions that should be automatically installed by Zed.
381    ///
382    /// This is used to make functionality provided by extensions (e.g., language support)
383    /// available out-of-the-box.
384    ///
385    /// Default: { "html": true }
386    #[serde(default)]
387    pub auto_install_extensions: HashMap<Arc<str>, bool>,
388    #[serde(default)]
389    pub auto_update_extensions: HashMap<Arc<str>, bool>,
390}
391
392#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, Debug)]
393pub struct GitPanelSettingsContent {
394    /// Whether to show the panel button in the status bar.
395    ///
396    /// Default: true
397    pub button: Option<bool>,
398    /// Where to dock the panel.
399    ///
400    /// Default: left
401    pub dock: Option<DockPosition>,
402    /// Default width of the panel in pixels.
403    ///
404    /// Default: 360
405    pub default_width: Option<f32>,
406    /// How entry statuses are displayed.
407    ///
408    /// Default: icon
409    pub status_style: Option<StatusStyle>,
410    /// How and when the scrollbar should be displayed.
411    ///
412    /// Default: inherits editor scrollbar settings
413    pub scrollbar: Option<ScrollbarSettings>,
414
415    /// What the default branch name should be when
416    /// `init.defaultBranch` is not set in git
417    ///
418    /// Default: main
419    pub fallback_branch_name: Option<String>,
420
421    /// Whether to sort entries in the panel by path
422    /// or by status (the default).
423    ///
424    /// Default: false
425    pub sort_by_path: Option<bool>,
426
427    /// Whether to collapse untracked files in the diff panel.
428    ///
429    /// Default: false
430    pub collapse_untracked_diff: Option<bool>,
431}
432
433#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
434#[serde(rename_all = "snake_case")]
435pub enum StatusStyle {
436    #[default]
437    Icon,
438    LabelColor,
439}
440
441#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
442pub struct ScrollbarSettings {
443    pub show: Option<ShowScrollbar>,
444}
445
446#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, PartialEq)]
447pub struct NotificationPanelSettingsContent {
448    /// Whether to show the panel button in the status bar.
449    ///
450    /// Default: true
451    pub button: Option<bool>,
452    /// Where to dock the panel.
453    ///
454    /// Default: right
455    pub dock: Option<DockPosition>,
456    /// Default width of the panel in pixels.
457    ///
458    /// Default: 300
459    pub default_width: Option<f32>,
460}
461
462#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, PartialEq)]
463pub struct PanelSettingsContent {
464    /// Whether to show the panel button in the status bar.
465    ///
466    /// Default: true
467    pub button: Option<bool>,
468    /// Where to dock the panel.
469    ///
470    /// Default: left
471    pub dock: Option<DockPosition>,
472    /// Default width of the panel in pixels.
473    ///
474    /// Default: 240
475    pub default_width: Option<f32>,
476}
477
478#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, PartialEq)]
479pub struct MessageEditorSettings {
480    /// Whether to automatically replace emoji shortcodes with emoji characters.
481    /// For example: typing `:wave:` gets replaced with `👋`.
482    ///
483    /// Default: false
484    pub auto_replace_emoji_shortcode: Option<bool>,
485}
486
487#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, PartialEq)]
488pub struct FileFinderSettingsContent {
489    /// Whether to show file icons in the file finder.
490    ///
491    /// Default: true
492    pub file_icons: Option<bool>,
493    /// Determines how much space the file finder can take up in relation to the available window width.
494    ///
495    /// Default: small
496    pub modal_max_width: Option<FileFinderWidthContent>,
497    /// Determines whether the file finder should skip focus for the active file in search results.
498    ///
499    /// Default: true
500    pub skip_focus_for_active_in_search: Option<bool>,
501    /// Determines whether to show the git status in the file finder
502    ///
503    /// Default: true
504    pub git_status: Option<bool>,
505    /// Whether to use gitignored files when searching.
506    /// Only the file Zed had indexed will be used, not necessary all the gitignored files.
507    ///
508    /// Can accept 3 values:
509    /// * `Some(true)`: Use all gitignored files
510    /// * `Some(false)`: Use only the files Zed had indexed
511    /// * `None`: Be smart and search for ignored when called from a gitignored worktree
512    ///
513    /// Default: None
514    /// todo!() -> Change this type to an enum
515    pub include_ignored: Option<Option<bool>>,
516}
517
518#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, Serialize, Deserialize, JsonSchema)]
519#[serde(rename_all = "lowercase")]
520pub enum FileFinderWidthContent {
521    #[default]
522    Small,
523    Medium,
524    Large,
525    XLarge,
526    Full,
527}
528
529#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug, JsonSchema)]
530pub struct VimSettingsContent {
531    pub default_mode: Option<ModeContent>,
532    pub toggle_relative_line_numbers: Option<bool>,
533    pub use_system_clipboard: Option<UseSystemClipboard>,
534    pub use_smartcase_find: Option<bool>,
535    pub custom_digraphs: Option<HashMap<String, Arc<str>>>,
536    pub highlight_on_yank_duration: Option<u64>,
537    pub cursor_shape: Option<CursorShapeSettings>,
538}
539
540#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, PartialEq, Debug)]
541#[serde(rename_all = "snake_case")]
542pub enum ModeContent {
543    #[default]
544    Normal,
545    Insert,
546    Replace,
547    Visual,
548    VisualLine,
549    VisualBlock,
550    HelixNormal,
551}
552
553/// Controls when to use system clipboard.
554#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
555#[serde(rename_all = "snake_case")]
556pub enum UseSystemClipboard {
557    /// Don't use system clipboard.
558    Never,
559    /// Use system clipboard.
560    Always,
561    /// Use system clipboard for yank operations.
562    OnYank,
563}
564
565/// The settings for cursor shape.
566#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
567pub struct CursorShapeSettings {
568    /// Cursor shape for the normal mode.
569    ///
570    /// Default: block
571    pub normal: Option<CursorShape>,
572    /// Cursor shape for the replace mode.
573    ///
574    /// Default: underline
575    pub replace: Option<CursorShape>,
576    /// Cursor shape for the visual mode.
577    ///
578    /// Default: block
579    pub visual: Option<CursorShape>,
580    /// Cursor shape for the insert mode.
581    ///
582    /// The default value follows the primary cursor_shape.
583    pub insert: Option<CursorShape>,
584}
585
586/// Settings specific to journaling
587#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
588pub struct JournalSettingsContent {
589    /// The path of the directory where journal entries are stored.
590    ///
591    /// Default: `~`
592    pub path: Option<String>,
593    /// What format to display the hours in.
594    ///
595    /// Default: hour12
596    pub hour_format: Option<HourFormatContent>,
597}
598
599#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq)]
600#[serde(rename_all = "snake_case")]
601pub enum HourFormatContent {
602    #[default]
603    Hour12,
604    Hour24,
605}
606
607#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, PartialEq)]
608pub struct OutlinePanelSettingsContent {
609    /// Whether to show the outline panel button in the status bar.
610    ///
611    /// Default: true
612    pub button: Option<bool>,
613    /// Customize default width (in pixels) taken by outline panel
614    ///
615    /// Default: 240
616    pub default_width: Option<f32>,
617    /// The position of outline panel
618    ///
619    /// Default: left
620    pub dock: Option<OutlinePanelDockPosition>,
621    /// Whether to show file icons in the outline panel.
622    ///
623    /// Default: true
624    pub file_icons: Option<bool>,
625    /// Whether to show folder icons or chevrons for directories in the outline panel.
626    ///
627    /// Default: true
628    pub folder_icons: Option<bool>,
629    /// Whether to show the git status in the outline panel.
630    ///
631    /// Default: true
632    pub git_status: Option<bool>,
633    /// Amount of indentation (in pixels) for nested items.
634    ///
635    /// Default: 20
636    pub indent_size: Option<f32>,
637    /// Whether to reveal it in the outline panel automatically,
638    /// when a corresponding project entry becomes active.
639    /// Gitignored entries are never auto revealed.
640    ///
641    /// Default: true
642    pub auto_reveal_entries: Option<bool>,
643    /// Whether to fold directories automatically
644    /// when directory has only one directory inside.
645    ///
646    /// Default: true
647    pub auto_fold_dirs: Option<bool>,
648    /// Settings related to indent guides in the outline panel.
649    pub indent_guides: Option<IndentGuidesSettingsContent>,
650    /// Scrollbar-related settings
651    pub scrollbar: Option<ScrollbarSettingsContent>,
652    /// Default depth to expand outline items in the current file.
653    /// The default depth to which outline entries are expanded on reveal.
654    /// - Set to 0 to collapse all items that have children
655    /// - Set to 1 or higher to collapse items at that depth or deeper
656    ///
657    /// Default: 100
658    pub expand_outlines_with_depth: Option<usize>,
659}
660
661#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, Copy, PartialEq)]
662#[serde(rename_all = "snake_case")]
663pub enum OutlinePanelDockPosition {
664    Left,
665    Right,
666}
667
668#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
669#[serde(rename_all = "snake_case")]
670pub enum ShowIndentGuides {
671    Always,
672    Never,
673}
674
675#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
676pub struct IndentGuidesSettingsContent {
677    /// When to show the scrollbar in the outline panel.
678    pub show: Option<ShowIndentGuides>,
679}
680
681#[derive(Clone, Copy, Default, PartialEq, Debug, JsonSchema, Deserialize, Serialize)]
682#[serde(rename_all = "snake_case")]
683pub enum LineIndicatorFormat {
684    Short,
685    #[default]
686    Long,
687}