settings_content.rs

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