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