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(
401    Copy,
402    Clone,
403    Debug,
404    Serialize,
405    Deserialize,
406    JsonSchema,
407    MergeFrom,
408    PartialEq,
409    Eq,
410    strum::VariantArray,
411    strum::VariantNames,
412)]
413#[serde(rename_all = "snake_case")]
414pub enum DockPosition {
415    Left,
416    Bottom,
417    Right,
418}
419
420/// Settings for slash commands.
421#[skip_serializing_none]
422#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, MergeFrom, PartialEq, Eq)]
423pub struct SlashCommandSettings {
424    /// Settings for the `/cargo-workspace` slash command.
425    pub cargo_workspace: Option<CargoWorkspaceCommandSettings>,
426}
427
428/// Settings for the `/cargo-workspace` slash command.
429#[skip_serializing_none]
430#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, MergeFrom, PartialEq, Eq)]
431pub struct CargoWorkspaceCommandSettings {
432    /// Whether `/cargo-workspace` is enabled.
433    pub enabled: Option<bool>,
434}
435
436/// Configuration of voice calls in Zed.
437#[skip_serializing_none]
438#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
439pub struct CallSettingsContent {
440    /// Whether the microphone should be muted when joining a channel or a call.
441    ///
442    /// Default: false
443    pub mute_on_join: Option<bool>,
444
445    /// Whether your current project should be shared when joining an empty channel.
446    ///
447    /// Default: false
448    pub share_on_join: Option<bool>,
449}
450
451#[skip_serializing_none]
452#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
453pub struct GitPanelSettingsContent {
454    /// Whether to show the panel button in the status bar.
455    ///
456    /// Default: true
457    pub button: Option<bool>,
458    /// Where to dock the panel.
459    ///
460    /// Default: left
461    pub dock: Option<DockPosition>,
462    /// Default width of the panel in pixels.
463    ///
464    /// Default: 360
465    pub default_width: Option<f32>,
466    /// How entry statuses are displayed.
467    ///
468    /// Default: icon
469    pub status_style: Option<StatusStyle>,
470    /// How and when the scrollbar should be displayed.
471    ///
472    /// Default: inherits editor scrollbar settings
473    pub scrollbar: Option<ScrollbarSettings>,
474
475    /// What the default branch name should be when
476    /// `init.defaultBranch` is not set in git
477    ///
478    /// Default: main
479    pub fallback_branch_name: Option<String>,
480
481    /// Whether to sort entries in the panel by path
482    /// or by status (the default).
483    ///
484    /// Default: false
485    pub sort_by_path: Option<bool>,
486
487    /// Whether to collapse untracked files in the diff panel.
488    ///
489    /// Default: false
490    pub collapse_untracked_diff: Option<bool>,
491}
492
493#[derive(
494    Default, Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
495)]
496#[serde(rename_all = "snake_case")]
497pub enum StatusStyle {
498    #[default]
499    Icon,
500    LabelColor,
501}
502
503#[skip_serializing_none]
504#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
505pub struct ScrollbarSettings {
506    pub show: Option<ShowScrollbar>,
507}
508
509#[skip_serializing_none]
510#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
511pub struct NotificationPanelSettingsContent {
512    /// Whether to show the panel button in the status bar.
513    ///
514    /// Default: true
515    pub button: Option<bool>,
516    /// Where to dock the panel.
517    ///
518    /// Default: right
519    pub dock: Option<DockPosition>,
520    /// Default width of the panel in pixels.
521    ///
522    /// Default: 300
523    pub default_width: Option<f32>,
524}
525
526#[skip_serializing_none]
527#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
528pub struct PanelSettingsContent {
529    /// Whether to show the panel button in the status bar.
530    ///
531    /// Default: true
532    pub button: Option<bool>,
533    /// Where to dock the panel.
534    ///
535    /// Default: left
536    pub dock: Option<DockPosition>,
537    /// Default width of the panel in pixels.
538    ///
539    /// Default: 240
540    pub default_width: Option<f32>,
541}
542
543#[skip_serializing_none]
544#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
545pub struct MessageEditorSettings {
546    /// Whether to automatically replace emoji shortcodes with emoji characters.
547    /// For example: typing `:wave:` gets replaced with `👋`.
548    ///
549    /// Default: false
550    pub auto_replace_emoji_shortcode: Option<bool>,
551}
552
553#[skip_serializing_none]
554#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
555pub struct FileFinderSettingsContent {
556    /// Whether to show file icons in the file finder.
557    ///
558    /// Default: true
559    pub file_icons: Option<bool>,
560    /// Determines how much space the file finder can take up in relation to the available window width.
561    ///
562    /// Default: small
563    pub modal_max_width: Option<FileFinderWidthContent>,
564    /// Determines whether the file finder should skip focus for the active file in search results.
565    ///
566    /// Default: true
567    pub skip_focus_for_active_in_search: Option<bool>,
568    /// Determines whether to show the git status in the file finder
569    ///
570    /// Default: true
571    pub git_status: Option<bool>,
572    /// Whether to use gitignored files when searching.
573    /// Only the file Zed had indexed will be used, not necessary all the gitignored files.
574    ///
575    /// Can accept 3 values:
576    /// * `Some(true)`: Use all gitignored files
577    /// * `Some(false)`: Use only the files Zed had indexed
578    /// * `None`: Be smart and search for ignored when called from a gitignored worktree
579    ///
580    /// Default: None
581    /// todo() -> Change this type to an enum
582    pub include_ignored: Option<bool>,
583}
584
585#[derive(
586    Debug,
587    PartialEq,
588    Eq,
589    Clone,
590    Copy,
591    Default,
592    Serialize,
593    Deserialize,
594    JsonSchema,
595    MergeFrom,
596    strum::VariantArray,
597    strum::VariantNames,
598)]
599#[serde(rename_all = "lowercase")]
600pub enum FileFinderWidthContent {
601    #[default]
602    Small,
603    Medium,
604    Large,
605    XLarge,
606    Full,
607}
608
609#[skip_serializing_none]
610#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug, JsonSchema, MergeFrom)]
611pub struct VimSettingsContent {
612    pub default_mode: Option<ModeContent>,
613    pub toggle_relative_line_numbers: Option<bool>,
614    pub use_system_clipboard: Option<UseSystemClipboard>,
615    pub use_smartcase_find: Option<bool>,
616    pub custom_digraphs: Option<HashMap<String, Arc<str>>>,
617    pub highlight_on_yank_duration: Option<u64>,
618    pub cursor_shape: Option<CursorShapeSettings>,
619}
620
621#[derive(Copy, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Debug)]
622#[serde(rename_all = "snake_case")]
623pub enum ModeContent {
624    #[default]
625    Normal,
626    Insert,
627}
628
629/// Controls when to use system clipboard.
630#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
631#[serde(rename_all = "snake_case")]
632pub enum UseSystemClipboard {
633    /// Don't use system clipboard.
634    Never,
635    /// Use system clipboard.
636    Always,
637    /// Use system clipboard for yank operations.
638    OnYank,
639}
640
641/// The settings for cursor shape.
642#[skip_serializing_none]
643#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
644pub struct CursorShapeSettings {
645    /// Cursor shape for the normal mode.
646    ///
647    /// Default: block
648    pub normal: Option<CursorShape>,
649    /// Cursor shape for the replace mode.
650    ///
651    /// Default: underline
652    pub replace: Option<CursorShape>,
653    /// Cursor shape for the visual mode.
654    ///
655    /// Default: block
656    pub visual: Option<CursorShape>,
657    /// Cursor shape for the insert mode.
658    ///
659    /// The default value follows the primary cursor_shape.
660    pub insert: Option<CursorShape>,
661}
662
663/// Settings specific to journaling
664#[skip_serializing_none]
665#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
666pub struct JournalSettingsContent {
667    /// The path of the directory where journal entries are stored.
668    ///
669    /// Default: `~`
670    pub path: Option<String>,
671    /// What format to display the hours in.
672    ///
673    /// Default: hour12
674    pub hour_format: Option<HourFormat>,
675}
676
677#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
678#[serde(rename_all = "snake_case")]
679pub enum HourFormat {
680    #[default]
681    Hour12,
682    Hour24,
683}
684
685#[skip_serializing_none]
686#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
687pub struct OutlinePanelSettingsContent {
688    /// Whether to show the outline panel button in the status bar.
689    ///
690    /// Default: true
691    pub button: Option<bool>,
692    /// Customize default width (in pixels) taken by outline panel
693    ///
694    /// Default: 240
695    pub default_width: Option<f32>,
696    /// The position of outline panel
697    ///
698    /// Default: left
699    pub dock: Option<DockSide>,
700    /// Whether to show file icons in the outline panel.
701    ///
702    /// Default: true
703    pub file_icons: Option<bool>,
704    /// Whether to show folder icons or chevrons for directories in the outline panel.
705    ///
706    /// Default: true
707    pub folder_icons: Option<bool>,
708    /// Whether to show the git status in the outline panel.
709    ///
710    /// Default: true
711    pub git_status: Option<bool>,
712    /// Amount of indentation (in pixels) for nested items.
713    ///
714    /// Default: 20
715    pub indent_size: Option<f32>,
716    /// Whether to reveal it in the outline panel automatically,
717    /// when a corresponding project entry becomes active.
718    /// Gitignored entries are never auto revealed.
719    ///
720    /// Default: true
721    pub auto_reveal_entries: Option<bool>,
722    /// Whether to fold directories automatically
723    /// when directory has only one directory inside.
724    ///
725    /// Default: true
726    pub auto_fold_dirs: Option<bool>,
727    /// Settings related to indent guides in the outline panel.
728    pub indent_guides: Option<IndentGuidesSettingsContent>,
729    /// Scrollbar-related settings
730    pub scrollbar: Option<ScrollbarSettingsContent>,
731    /// Default depth to expand outline items in the current file.
732    /// The default depth to which outline entries are expanded on reveal.
733    /// - Set to 0 to collapse all items that have children
734    /// - Set to 1 or higher to collapse items at that depth or deeper
735    ///
736    /// Default: 100
737    pub expand_outlines_with_depth: Option<usize>,
738}
739
740#[derive(
741    Clone,
742    Copy,
743    Debug,
744    PartialEq,
745    Eq,
746    Serialize,
747    Deserialize,
748    JsonSchema,
749    MergeFrom,
750    strum::VariantArray,
751    strum::VariantNames,
752)]
753#[serde(rename_all = "snake_case")]
754pub enum DockSide {
755    Left,
756    Right,
757}
758
759#[derive(
760    Copy,
761    Clone,
762    Debug,
763    PartialEq,
764    Eq,
765    Deserialize,
766    Serialize,
767    JsonSchema,
768    MergeFrom,
769    strum::VariantArray,
770    strum::VariantNames,
771)]
772#[serde(rename_all = "snake_case")]
773pub enum ShowIndentGuides {
774    Always,
775    Never,
776}
777
778#[skip_serializing_none]
779#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
780pub struct IndentGuidesSettingsContent {
781    /// When to show the scrollbar in the outline panel.
782    pub show: Option<ShowIndentGuides>,
783}
784
785#[derive(Clone, Copy, Default, PartialEq, Debug, JsonSchema, MergeFrom, Deserialize, Serialize)]
786#[serde(rename_all = "snake_case")]
787pub enum LineIndicatorFormat {
788    Short,
789    #[default]
790    Long,
791}
792
793/// The settings for the image viewer.
794#[skip_serializing_none]
795#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Default, PartialEq)]
796pub struct ImageViewerSettingsContent {
797    /// The unit to use for displaying image file sizes.
798    ///
799    /// Default: "binary"
800    pub unit: Option<ImageFileSizeUnit>,
801}
802
803#[skip_serializing_none]
804#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Default, PartialEq)]
805#[serde(rename_all = "snake_case")]
806pub enum ImageFileSizeUnit {
807    /// Displays file size in binary units (e.g., KiB, MiB).
808    #[default]
809    Binary,
810    /// Displays file size in decimal units (e.g., KB, MB).
811    Decimal,
812}
813
814#[skip_serializing_none]
815#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
816pub struct RemoteSettingsContent {
817    pub ssh_connections: Option<Vec<SshConnection>>,
818    pub wsl_connections: Option<Vec<WslConnection>>,
819    pub read_ssh_config: Option<bool>,
820}
821
822#[skip_serializing_none]
823#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
824pub struct SshConnection {
825    pub host: SharedString,
826    pub username: Option<String>,
827    pub port: Option<u16>,
828    #[serde(default)]
829    pub args: Vec<String>,
830    #[serde(default)]
831    pub projects: collections::BTreeSet<SshProject>,
832    /// Name to use for this server in UI.
833    pub nickname: Option<String>,
834    // By default Zed will download the binary to the host directly.
835    // If this is set to true, Zed will download the binary to your local machine,
836    // and then upload it over the SSH connection. Useful if your SSH server has
837    // limited outbound internet access.
838    pub upload_binary_over_ssh: Option<bool>,
839
840    pub port_forwards: Option<Vec<SshPortForwardOption>>,
841}
842
843#[derive(Clone, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom, Debug)]
844pub struct WslConnection {
845    pub distro_name: SharedString,
846    pub user: Option<String>,
847    #[serde(default)]
848    pub projects: BTreeSet<SshProject>,
849}
850
851#[skip_serializing_none]
852#[derive(
853    Clone, Debug, Default, Serialize, PartialEq, Eq, PartialOrd, Ord, Deserialize, JsonSchema,
854)]
855pub struct SshProject {
856    pub paths: Vec<String>,
857}
858
859#[skip_serializing_none]
860#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema, MergeFrom)]
861pub struct SshPortForwardOption {
862    #[serde(skip_serializing_if = "Option::is_none")]
863    pub local_host: Option<String>,
864    pub local_port: u16,
865    #[serde(skip_serializing_if = "Option::is_none")]
866    pub remote_host: Option<String>,
867    pub remote_port: u16,
868}
869
870/// Settings for configuring REPL display and behavior.
871#[skip_serializing_none]
872#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
873pub struct ReplSettingsContent {
874    /// Maximum number of lines to keep in REPL's scrollback buffer.
875    /// Clamped with [4, 256] range.
876    ///
877    /// Default: 32
878    pub max_lines: Option<usize>,
879    /// Maximum number of columns to keep in REPL's scrollback buffer.
880    /// Clamped with [20, 512] range.
881    ///
882    /// Default: 128
883    pub max_columns: Option<usize>,
884}
885
886#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
887/// An ExtendingVec in the settings can only accumulate new values.
888///
889/// This is useful for things like private files where you only want
890/// to allow new values to be added.
891///
892/// Consider using a HashMap<String, bool> instead of this type
893/// (like auto_install_extensions) so that user settings files can both add
894/// and remove values from the set.
895pub struct ExtendingVec<T>(pub Vec<T>);
896
897impl<T> Into<Vec<T>> for ExtendingVec<T> {
898    fn into(self) -> Vec<T> {
899        self.0
900    }
901}
902impl<T> From<Vec<T>> for ExtendingVec<T> {
903    fn from(vec: Vec<T>) -> Self {
904        ExtendingVec(vec)
905    }
906}
907
908impl<T: Clone> merge_from::MergeFrom for ExtendingVec<T> {
909    fn merge_from(&mut self, other: &Self) {
910        self.0.extend_from_slice(other.0.as_slice());
911    }
912}
913
914/// A SaturatingBool in the settings can only ever be set to true,
915/// later attempts to set it to false will be ignored.
916///
917/// Used by `disable_ai`.
918#[derive(Debug, Default, Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
919pub struct SaturatingBool(pub bool);
920
921impl From<bool> for SaturatingBool {
922    fn from(value: bool) -> Self {
923        SaturatingBool(value)
924    }
925}
926
927impl From<SaturatingBool> for bool {
928    fn from(value: SaturatingBool) -> bool {
929        value.0
930    }
931}
932
933impl merge_from::MergeFrom for SaturatingBool {
934    fn merge_from(&mut self, other: &Self) {
935        self.0 |= other.0
936    }
937}