settings_content.rs

  1mod agent;
  2mod editor;
  3mod language;
  4mod language_model;
  5mod project;
  6mod terminal;
  7mod theme;
  8mod workspace;
  9
 10pub use agent::*;
 11pub use editor::*;
 12pub use language::*;
 13pub use language_model::*;
 14pub use project::*;
 15pub use terminal::*;
 16pub use theme::*;
 17pub use workspace::*;
 18
 19use collections::{HashMap, IndexMap};
 20use gpui::{App, SharedString};
 21use release_channel::ReleaseChannel;
 22use schemars::JsonSchema;
 23use serde::{Deserialize, Serialize};
 24use serde_with::skip_serializing_none;
 25use settings_macros::MergeFrom;
 26use std::collections::BTreeSet;
 27use std::env;
 28use std::sync::Arc;
 29pub use util::serde::default_true;
 30
 31use crate::{ActiveSettingsProfileName, merge_from};
 32
 33#[skip_serializing_none]
 34#[derive(Debug, PartialEq, Default, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
 35pub struct SettingsContent {
 36    #[serde(flatten)]
 37    pub project: ProjectSettingsContent,
 38
 39    #[serde(flatten)]
 40    pub theme: Box<ThemeSettingsContent>,
 41
 42    #[serde(flatten)]
 43    pub extension: ExtensionSettingsContent,
 44
 45    #[serde(flatten)]
 46    pub workspace: WorkspaceSettingsContent,
 47
 48    #[serde(flatten)]
 49    pub editor: EditorSettingsContent,
 50
 51    #[serde(flatten)]
 52    pub remote: RemoteSettingsContent,
 53
 54    /// Settings related to the file finder.
 55    pub file_finder: Option<FileFinderSettingsContent>,
 56
 57    pub git_panel: Option<GitPanelSettingsContent>,
 58
 59    pub tabs: Option<ItemSettingsContent>,
 60    pub tab_bar: Option<TabBarSettingsContent>,
 61
 62    pub preview_tabs: Option<PreviewTabsSettingsContent>,
 63
 64    pub agent: Option<AgentSettingsContent>,
 65    pub agent_servers: Option<AllAgentServersSettings>,
 66
 67    /// Configuration of audio in Zed.
 68    pub audio: Option<AudioSettingsContent>,
 69
 70    /// Whether or not to automatically check for updates.
 71    ///
 72    /// Default: true
 73    pub auto_update: Option<bool>,
 74
 75    /// This base keymap settings adjusts the default keybindings in Zed to be similar
 76    /// to other common code editors. By default, Zed's keymap closely follows VSCode's
 77    /// keymap, with minor adjustments, this corresponds to the "VSCode" setting.
 78    ///
 79    /// Default: VSCode
 80    pub base_keymap: Option<BaseKeymapContent>,
 81
 82    /// Configuration for the collab panel visual settings.
 83    pub collaboration_panel: Option<PanelSettingsContent>,
 84
 85    pub debugger: Option<DebuggerSettingsContent>,
 86
 87    /// Configuration for Diagnostics-related features.
 88    pub diagnostics: Option<DiagnosticsSettingsContent>,
 89
 90    /// Configuration for Git-related features
 91    pub git: Option<GitSettings>,
 92
 93    /// Common language server settings.
 94    pub global_lsp_settings: Option<GlobalLspSettingsContent>,
 95
 96    /// The settings for the image viewer.
 97    pub image_viewer: Option<ImageViewerSettingsContent>,
 98
 99    pub repl: Option<ReplSettingsContent>,
100
101    /// Whether or not to enable Helix mode.
102    ///
103    /// Default: false
104    pub helix_mode: Option<bool>,
105
106    pub journal: Option<JournalSettingsContent>,
107
108    /// A map of log scopes to the desired log level.
109    /// Useful for filtering out noisy logs or enabling more verbose logging.
110    ///
111    /// Example: {"log": {"client": "warn"}}
112    pub log: Option<HashMap<String, String>>,
113
114    pub line_indicator_format: Option<LineIndicatorFormat>,
115
116    pub language_models: Option<AllLanguageModelSettingsContent>,
117
118    pub outline_panel: Option<OutlinePanelSettingsContent>,
119
120    pub project_panel: Option<ProjectPanelSettingsContent>,
121
122    /// Configuration for the Message Editor
123    pub message_editor: Option<MessageEditorSettings>,
124
125    /// Configuration for Node-related features
126    pub node: Option<NodeBinarySettings>,
127
128    /// Configuration for the Notification Panel
129    pub notification_panel: Option<NotificationPanelSettingsContent>,
130
131    pub proxy: Option<String>,
132
133    /// The URL of the Zed server to connect to.
134    pub server_url: Option<String>,
135
136    /// Configuration for session-related features
137    pub session: Option<SessionSettingsContent>,
138    /// Control what info is collected by Zed.
139    pub telemetry: Option<TelemetrySettingsContent>,
140
141    /// Configuration of the terminal in Zed.
142    pub terminal: Option<TerminalSettingsContent>,
143
144    pub title_bar: Option<TitleBarSettingsContent>,
145
146    /// Whether or not to enable Vim mode.
147    ///
148    /// Default: false
149    pub vim_mode: Option<bool>,
150
151    // Settings related to calls in Zed
152    pub calls: Option<CallSettingsContent>,
153
154    /// Whether to disable all AI features in Zed.
155    ///
156    /// Default: false
157    pub disable_ai: Option<SaturatingBool>,
158
159    /// Settings related to Vim mode in Zed.
160    pub vim: Option<VimSettingsContent>,
161}
162
163impl SettingsContent {
164    pub fn languages_mut(&mut self) -> &mut HashMap<SharedString, LanguageSettingsContent> {
165        &mut self.project.all_languages.languages.0
166    }
167}
168
169#[skip_serializing_none]
170#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
171pub struct UserSettingsContent {
172    #[serde(flatten)]
173    pub content: Box<SettingsContent>,
174
175    pub dev: Option<Box<SettingsContent>>,
176    pub nightly: Option<Box<SettingsContent>>,
177    pub preview: Option<Box<SettingsContent>>,
178    pub stable: Option<Box<SettingsContent>>,
179
180    pub macos: Option<Box<SettingsContent>>,
181    pub windows: Option<Box<SettingsContent>>,
182    pub linux: Option<Box<SettingsContent>>,
183
184    #[serde(default)]
185    pub profiles: IndexMap<String, SettingsContent>,
186}
187
188pub struct ExtensionsSettingsContent {
189    pub all_languages: AllLanguageSettingsContent,
190}
191
192impl UserSettingsContent {
193    pub fn for_release_channel(&self) -> Option<&SettingsContent> {
194        match *release_channel::RELEASE_CHANNEL {
195            ReleaseChannel::Dev => self.dev.as_deref(),
196            ReleaseChannel::Nightly => self.nightly.as_deref(),
197            ReleaseChannel::Preview => self.preview.as_deref(),
198            ReleaseChannel::Stable => self.stable.as_deref(),
199        }
200    }
201
202    pub fn for_os(&self) -> Option<&SettingsContent> {
203        match env::consts::OS {
204            "macos" => self.macos.as_deref(),
205            "linux" => self.linux.as_deref(),
206            "windows" => self.windows.as_deref(),
207            _ => None,
208        }
209    }
210
211    pub fn for_profile(&self, cx: &App) -> Option<&SettingsContent> {
212        let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() else {
213            return None;
214        };
215        self.profiles.get(&active_profile.0)
216    }
217}
218
219/// Base key bindings scheme. Base keymaps can be overridden with user keymaps.
220///
221/// Default: VSCode
222#[derive(
223    Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq, Default,
224)]
225pub enum BaseKeymapContent {
226    #[default]
227    VSCode,
228    JetBrains,
229    SublimeText,
230    Atom,
231    TextMate,
232    Emacs,
233    Cursor,
234    None,
235}
236
237#[skip_serializing_none]
238#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
239pub struct TitleBarSettingsContent {
240    /// Whether to show the branch icon beside branch switcher in the title bar.
241    ///
242    /// Default: false
243    pub show_branch_icon: Option<bool>,
244    /// Whether to show onboarding banners in the title bar.
245    ///
246    /// Default: true
247    pub show_onboarding_banner: Option<bool>,
248    /// Whether to show user avatar in the title bar.
249    ///
250    /// Default: true
251    pub show_user_picture: Option<bool>,
252    /// Whether to show the branch name button in the titlebar.
253    ///
254    /// Default: true
255    pub show_branch_name: Option<bool>,
256    /// Whether to show the project host and name in the titlebar.
257    ///
258    /// Default: true
259    pub show_project_items: Option<bool>,
260    /// Whether to show the sign in button in the title bar.
261    ///
262    /// Default: true
263    pub show_sign_in: Option<bool>,
264    /// Whether to show the menus in the title bar.
265    ///
266    /// Default: false
267    pub show_menus: Option<bool>,
268}
269
270/// Configuration of audio in Zed.
271#[skip_serializing_none]
272#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
273pub struct AudioSettingsContent {
274    /// Opt into the new audio system.
275    ///
276    /// You need to rejoin a call for this setting to apply
277    #[serde(rename = "experimental.rodio_audio")]
278    pub rodio_audio: Option<bool>, // default is false
279    /// Requires 'rodio_audio: true'
280    ///
281    /// Automatically increase or decrease you microphone's volume. This affects how
282    /// loud you sound to others.
283    ///
284    /// Recommended: off (default)
285    /// Microphones are too quite in zed, until everyone is on experimental
286    /// audio and has auto speaker volume on this will make you very loud
287    /// compared to other speakers.
288    #[serde(rename = "experimental.auto_microphone_volume")]
289    pub auto_microphone_volume: Option<bool>,
290    /// Requires 'rodio_audio: true'
291    ///
292    /// Automatically increate or decrease the volume of other call members.
293    /// This only affects how things sound for you.
294    #[serde(rename = "experimental.auto_speaker_volume")]
295    pub auto_speaker_volume: Option<bool>,
296    /// Requires 'rodio_audio: true'
297    ///
298    /// Remove background noises. Works great for typing, cars, dogs, AC. Does
299    /// not work well on music.
300    #[serde(rename = "experimental.denoise")]
301    pub denoise: Option<bool>,
302    /// Requires 'rodio_audio: true'
303    ///
304    /// Use audio parameters compatible with the previous versions of
305    /// experimental audio and non-experimental audio. When this is false you
306    /// will sound strange to anyone not on the latest experimental audio. In
307    /// the future we will migrate by setting this to false
308    ///
309    /// You need to rejoin a call for this setting to apply
310    #[serde(rename = "experimental.legacy_audio_compatible")]
311    pub legacy_audio_compatible: Option<bool>,
312}
313
314/// Control what info is collected by Zed.
315#[skip_serializing_none]
316#[derive(Default, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Debug, MergeFrom)]
317pub struct TelemetrySettingsContent {
318    /// Send debug info like crash reports.
319    ///
320    /// Default: true
321    pub diagnostics: Option<bool>,
322    /// Send anonymized usage data like what languages you're using Zed with.
323    ///
324    /// Default: true
325    pub metrics: Option<bool>,
326}
327
328#[skip_serializing_none]
329#[derive(Default, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Clone, MergeFrom)]
330pub struct DebuggerSettingsContent {
331    /// Determines the stepping granularity.
332    ///
333    /// Default: line
334    pub stepping_granularity: Option<SteppingGranularity>,
335    /// Whether the breakpoints should be reused across Zed sessions.
336    ///
337    /// Default: true
338    pub save_breakpoints: Option<bool>,
339    /// Whether to show the debug button in the status bar.
340    ///
341    /// Default: true
342    pub button: Option<bool>,
343    /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
344    ///
345    /// Default: 2000ms
346    pub timeout: Option<u64>,
347    /// Whether to log messages between active debug adapters and Zed
348    ///
349    /// Default: true
350    pub log_dap_communications: Option<bool>,
351    /// Whether to format dap messages in when adding them to debug adapter logger
352    ///
353    /// Default: true
354    pub format_dap_log_messages: Option<bool>,
355    /// The dock position of the debug panel
356    ///
357    /// Default: Bottom
358    pub dock: Option<DockPosition>,
359}
360
361/// The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
362#[derive(
363    PartialEq, Eq, Debug, Hash, Clone, Copy, Deserialize, Serialize, JsonSchema, MergeFrom,
364)]
365#[serde(rename_all = "snake_case")]
366pub enum SteppingGranularity {
367    /// The step should allow the program to run until the current statement has finished executing.
368    /// The meaning of a statement is determined by the adapter and it may be considered equivalent to a line.
369    /// For example 'for(int i = 0; i < 10; i++)' could be considered to have 3 statements 'int i = 0', 'i < 10', and 'i++'.
370    Statement,
371    /// The step should allow the program to run until the current source line has executed.
372    Line,
373    /// The step should allow one instruction to execute (e.g. one x86 instruction).
374    Instruction,
375}
376
377#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
378#[serde(rename_all = "snake_case")]
379pub enum DockPosition {
380    Left,
381    Bottom,
382    Right,
383}
384
385/// Settings for slash commands.
386#[skip_serializing_none]
387#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, MergeFrom, PartialEq, Eq)]
388pub struct SlashCommandSettings {
389    /// Settings for the `/cargo-workspace` slash command.
390    pub cargo_workspace: Option<CargoWorkspaceCommandSettings>,
391}
392
393/// Settings for the `/cargo-workspace` slash command.
394#[skip_serializing_none]
395#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, MergeFrom, PartialEq, Eq)]
396pub struct CargoWorkspaceCommandSettings {
397    /// Whether `/cargo-workspace` is enabled.
398    pub enabled: Option<bool>,
399}
400
401/// Configuration of voice calls in Zed.
402#[skip_serializing_none]
403#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
404pub struct CallSettingsContent {
405    /// Whether the microphone should be muted when joining a channel or a call.
406    ///
407    /// Default: false
408    pub mute_on_join: Option<bool>,
409
410    /// Whether your current project should be shared when joining an empty channel.
411    ///
412    /// Default: false
413    pub share_on_join: Option<bool>,
414}
415
416#[skip_serializing_none]
417#[derive(Deserialize, Serialize, PartialEq, Debug, Default, Clone, JsonSchema, MergeFrom)]
418pub struct ExtensionSettingsContent {
419    /// The extensions that should be automatically installed by Zed.
420    ///
421    /// This is used to make functionality provided by extensions (e.g., language support)
422    /// available out-of-the-box.
423    ///
424    /// Default: { "html": true }
425    #[serde(default)]
426    pub auto_install_extensions: HashMap<Arc<str>, bool>,
427    #[serde(default)]
428    pub auto_update_extensions: HashMap<Arc<str>, bool>,
429}
430
431#[skip_serializing_none]
432#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
433pub struct GitPanelSettingsContent {
434    /// Whether to show the panel button in the status bar.
435    ///
436    /// Default: true
437    pub button: Option<bool>,
438    /// Where to dock the panel.
439    ///
440    /// Default: left
441    pub dock: Option<DockPosition>,
442    /// Default width of the panel in pixels.
443    ///
444    /// Default: 360
445    pub default_width: Option<f32>,
446    /// How entry statuses are displayed.
447    ///
448    /// Default: icon
449    pub status_style: Option<StatusStyle>,
450    /// How and when the scrollbar should be displayed.
451    ///
452    /// Default: inherits editor scrollbar settings
453    pub scrollbar: Option<ScrollbarSettings>,
454
455    /// What the default branch name should be when
456    /// `init.defaultBranch` is not set in git
457    ///
458    /// Default: main
459    pub fallback_branch_name: Option<String>,
460
461    /// Whether to sort entries in the panel by path
462    /// or by status (the default).
463    ///
464    /// Default: false
465    pub sort_by_path: Option<bool>,
466
467    /// Whether to collapse untracked files in the diff panel.
468    ///
469    /// Default: false
470    pub collapse_untracked_diff: Option<bool>,
471}
472
473#[derive(
474    Default, Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
475)]
476#[serde(rename_all = "snake_case")]
477pub enum StatusStyle {
478    #[default]
479    Icon,
480    LabelColor,
481}
482
483#[skip_serializing_none]
484#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
485pub struct ScrollbarSettings {
486    pub show: Option<ShowScrollbar>,
487}
488
489#[skip_serializing_none]
490#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
491pub struct NotificationPanelSettingsContent {
492    /// Whether to show the panel button in the status bar.
493    ///
494    /// Default: true
495    pub button: Option<bool>,
496    /// Where to dock the panel.
497    ///
498    /// Default: right
499    pub dock: Option<DockPosition>,
500    /// Default width of the panel in pixels.
501    ///
502    /// Default: 300
503    pub default_width: Option<f32>,
504}
505
506#[skip_serializing_none]
507#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
508pub struct PanelSettingsContent {
509    /// Whether to show the panel button in the status bar.
510    ///
511    /// Default: true
512    pub button: Option<bool>,
513    /// Where to dock the panel.
514    ///
515    /// Default: left
516    pub dock: Option<DockPosition>,
517    /// Default width of the panel in pixels.
518    ///
519    /// Default: 240
520    pub default_width: Option<f32>,
521}
522
523#[skip_serializing_none]
524#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
525pub struct MessageEditorSettings {
526    /// Whether to automatically replace emoji shortcodes with emoji characters.
527    /// For example: typing `:wave:` gets replaced with `👋`.
528    ///
529    /// Default: false
530    pub auto_replace_emoji_shortcode: Option<bool>,
531}
532
533#[skip_serializing_none]
534#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
535pub struct FileFinderSettingsContent {
536    /// Whether to show file icons in the file finder.
537    ///
538    /// Default: true
539    pub file_icons: Option<bool>,
540    /// Determines how much space the file finder can take up in relation to the available window width.
541    ///
542    /// Default: small
543    pub modal_max_width: Option<FileFinderWidthContent>,
544    /// Determines whether the file finder should skip focus for the active file in search results.
545    ///
546    /// Default: true
547    pub skip_focus_for_active_in_search: Option<bool>,
548    /// Determines whether to show the git status in the file finder
549    ///
550    /// Default: true
551    pub git_status: Option<bool>,
552    /// Whether to use gitignored files when searching.
553    /// Only the file Zed had indexed will be used, not necessary all the gitignored files.
554    ///
555    /// Can accept 3 values:
556    /// * `Some(true)`: Use all gitignored files
557    /// * `Some(false)`: Use only the files Zed had indexed
558    /// * `None`: Be smart and search for ignored when called from a gitignored worktree
559    ///
560    /// Default: None
561    /// todo() -> Change this type to an enum
562    pub include_ignored: Option<bool>,
563}
564
565#[derive(
566    Debug, PartialEq, Eq, Clone, Copy, Default, Serialize, Deserialize, JsonSchema, MergeFrom,
567)]
568#[serde(rename_all = "lowercase")]
569pub enum FileFinderWidthContent {
570    #[default]
571    Small,
572    Medium,
573    Large,
574    XLarge,
575    Full,
576}
577
578#[skip_serializing_none]
579#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug, JsonSchema, MergeFrom)]
580pub struct VimSettingsContent {
581    pub default_mode: Option<ModeContent>,
582    pub toggle_relative_line_numbers: Option<bool>,
583    pub use_system_clipboard: Option<UseSystemClipboard>,
584    pub use_smartcase_find: Option<bool>,
585    pub custom_digraphs: Option<HashMap<String, Arc<str>>>,
586    pub highlight_on_yank_duration: Option<u64>,
587    pub cursor_shape: Option<CursorShapeSettings>,
588}
589
590#[derive(Copy, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Debug)]
591#[serde(rename_all = "snake_case")]
592pub enum ModeContent {
593    #[default]
594    Normal,
595    Insert,
596}
597
598/// Controls when to use system clipboard.
599#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
600#[serde(rename_all = "snake_case")]
601pub enum UseSystemClipboard {
602    /// Don't use system clipboard.
603    Never,
604    /// Use system clipboard.
605    Always,
606    /// Use system clipboard for yank operations.
607    OnYank,
608}
609
610/// The settings for cursor shape.
611#[skip_serializing_none]
612#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
613pub struct CursorShapeSettings {
614    /// Cursor shape for the normal mode.
615    ///
616    /// Default: block
617    pub normal: Option<CursorShape>,
618    /// Cursor shape for the replace mode.
619    ///
620    /// Default: underline
621    pub replace: Option<CursorShape>,
622    /// Cursor shape for the visual mode.
623    ///
624    /// Default: block
625    pub visual: Option<CursorShape>,
626    /// Cursor shape for the insert mode.
627    ///
628    /// The default value follows the primary cursor_shape.
629    pub insert: Option<CursorShape>,
630}
631
632/// Settings specific to journaling
633#[skip_serializing_none]
634#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
635pub struct JournalSettingsContent {
636    /// The path of the directory where journal entries are stored.
637    ///
638    /// Default: `~`
639    pub path: Option<String>,
640    /// What format to display the hours in.
641    ///
642    /// Default: hour12
643    pub hour_format: Option<HourFormat>,
644}
645
646#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
647#[serde(rename_all = "snake_case")]
648pub enum HourFormat {
649    #[default]
650    Hour12,
651    Hour24,
652}
653
654#[skip_serializing_none]
655#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
656pub struct OutlinePanelSettingsContent {
657    /// Whether to show the outline panel button in the status bar.
658    ///
659    /// Default: true
660    pub button: Option<bool>,
661    /// Customize default width (in pixels) taken by outline panel
662    ///
663    /// Default: 240
664    pub default_width: Option<f32>,
665    /// The position of outline panel
666    ///
667    /// Default: left
668    pub dock: Option<DockSide>,
669    /// Whether to show file icons in the outline panel.
670    ///
671    /// Default: true
672    pub file_icons: Option<bool>,
673    /// Whether to show folder icons or chevrons for directories in the outline panel.
674    ///
675    /// Default: true
676    pub folder_icons: Option<bool>,
677    /// Whether to show the git status in the outline panel.
678    ///
679    /// Default: true
680    pub git_status: Option<bool>,
681    /// Amount of indentation (in pixels) for nested items.
682    ///
683    /// Default: 20
684    pub indent_size: Option<f32>,
685    /// Whether to reveal it in the outline panel automatically,
686    /// when a corresponding project entry becomes active.
687    /// Gitignored entries are never auto revealed.
688    ///
689    /// Default: true
690    pub auto_reveal_entries: Option<bool>,
691    /// Whether to fold directories automatically
692    /// when directory has only one directory inside.
693    ///
694    /// Default: true
695    pub auto_fold_dirs: Option<bool>,
696    /// Settings related to indent guides in the outline panel.
697    pub indent_guides: Option<IndentGuidesSettingsContent>,
698    /// Scrollbar-related settings
699    pub scrollbar: Option<ScrollbarSettingsContent>,
700    /// Default depth to expand outline items in the current file.
701    /// The default depth to which outline entries are expanded on reveal.
702    /// - Set to 0 to collapse all items that have children
703    /// - Set to 1 or higher to collapse items at that depth or deeper
704    ///
705    /// Default: 100
706    pub expand_outlines_with_depth: Option<usize>,
707}
708
709#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Copy, PartialEq)]
710#[serde(rename_all = "snake_case")]
711pub enum DockSide {
712    Left,
713    Right,
714}
715
716#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, JsonSchema, MergeFrom)]
717#[serde(rename_all = "snake_case")]
718pub enum ShowIndentGuides {
719    Always,
720    Never,
721}
722
723#[skip_serializing_none]
724#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
725pub struct IndentGuidesSettingsContent {
726    /// When to show the scrollbar in the outline panel.
727    pub show: Option<ShowIndentGuides>,
728}
729
730#[derive(Clone, Copy, Default, PartialEq, Debug, JsonSchema, MergeFrom, Deserialize, Serialize)]
731#[serde(rename_all = "snake_case")]
732pub enum LineIndicatorFormat {
733    Short,
734    #[default]
735    Long,
736}
737
738/// The settings for the image viewer.
739#[skip_serializing_none]
740#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Default, PartialEq)]
741pub struct ImageViewerSettingsContent {
742    /// The unit to use for displaying image file sizes.
743    ///
744    /// Default: "binary"
745    pub unit: Option<ImageFileSizeUnit>,
746}
747
748#[skip_serializing_none]
749#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Default, PartialEq)]
750#[serde(rename_all = "snake_case")]
751pub enum ImageFileSizeUnit {
752    /// Displays file size in binary units (e.g., KiB, MiB).
753    #[default]
754    Binary,
755    /// Displays file size in decimal units (e.g., KB, MB).
756    Decimal,
757}
758
759#[skip_serializing_none]
760#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
761pub struct RemoteSettingsContent {
762    pub ssh_connections: Option<Vec<SshConnection>>,
763    pub wsl_connections: Option<Vec<WslConnection>>,
764    pub read_ssh_config: Option<bool>,
765}
766
767#[skip_serializing_none]
768#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
769pub struct SshConnection {
770    pub host: SharedString,
771    pub username: Option<String>,
772    pub port: Option<u16>,
773    #[serde(default)]
774    pub args: Vec<String>,
775    #[serde(default)]
776    pub projects: collections::BTreeSet<SshProject>,
777    /// Name to use for this server in UI.
778    pub nickname: Option<String>,
779    // By default Zed will download the binary to the host directly.
780    // If this is set to true, Zed will download the binary to your local machine,
781    // and then upload it over the SSH connection. Useful if your SSH server has
782    // limited outbound internet access.
783    pub upload_binary_over_ssh: Option<bool>,
784
785    pub port_forwards: Option<Vec<SshPortForwardOption>>,
786}
787
788#[derive(Clone, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom, Debug)]
789pub struct WslConnection {
790    pub distro_name: SharedString,
791    pub user: Option<String>,
792    #[serde(default)]
793    pub projects: BTreeSet<SshProject>,
794}
795
796#[skip_serializing_none]
797#[derive(
798    Clone, Debug, Default, Serialize, PartialEq, Eq, PartialOrd, Ord, Deserialize, JsonSchema,
799)]
800pub struct SshProject {
801    pub paths: Vec<String>,
802}
803
804#[skip_serializing_none]
805#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema, MergeFrom)]
806pub struct SshPortForwardOption {
807    #[serde(skip_serializing_if = "Option::is_none")]
808    pub local_host: Option<String>,
809    pub local_port: u16,
810    #[serde(skip_serializing_if = "Option::is_none")]
811    pub remote_host: Option<String>,
812    pub remote_port: u16,
813}
814
815/// Settings for configuring REPL display and behavior.
816#[skip_serializing_none]
817#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
818pub struct ReplSettingsContent {
819    /// Maximum number of lines to keep in REPL's scrollback buffer.
820    /// Clamped with [4, 256] range.
821    ///
822    /// Default: 32
823    pub max_lines: Option<usize>,
824    /// Maximum number of columns to keep in REPL's scrollback buffer.
825    /// Clamped with [20, 512] range.
826    ///
827    /// Default: 128
828    pub max_columns: Option<usize>,
829}
830
831#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
832/// An ExtendingVec in the settings can only accumulate new values.
833///
834/// This is useful for things like private files where you only want
835/// to allow new values to be added.
836///
837/// Consider using a HashMap<String, bool> instead of this type
838/// (like auto_install_extensions) so that user settings files can both add
839/// and remove values from the set.
840pub struct ExtendingVec<T>(pub Vec<T>);
841
842impl<T> Into<Vec<T>> for ExtendingVec<T> {
843    fn into(self) -> Vec<T> {
844        self.0
845    }
846}
847impl<T> From<Vec<T>> for ExtendingVec<T> {
848    fn from(vec: Vec<T>) -> Self {
849        ExtendingVec(vec)
850    }
851}
852
853impl<T: Clone> merge_from::MergeFrom for ExtendingVec<T> {
854    fn merge_from(&mut self, other: &Self) {
855        self.0.extend_from_slice(other.0.as_slice());
856    }
857}
858
859/// A SaturatingBool in the settings can only ever be set to true,
860/// later attempts to set it to false will be ignored.
861///
862/// Used by `disable_ai`.
863#[derive(Debug, Default, Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
864pub struct SaturatingBool(pub bool);
865
866impl From<bool> for SaturatingBool {
867    fn from(value: bool) -> Self {
868        SaturatingBool(value)
869    }
870}
871
872impl From<SaturatingBool> for bool {
873    fn from(value: SaturatingBool) -> bool {
874        value.0
875    }
876}
877
878impl merge_from::MergeFrom for SaturatingBool {
879    fn merge_from(&mut self, other: &Self) {
880        self.0 |= other.0
881    }
882}