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