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)]
238pub enum BaseKeymapContent {
239 #[default]
240 VSCode,
241 JetBrains,
242 SublimeText,
243 Atom,
244 TextMate,
245 Emacs,
246 Cursor,
247 None,
248}
249
250impl strum::VariantNames for BaseKeymapContent {
251 const VARIANTS: &'static [&'static str] = &[
252 "VSCode",
253 "JetBrains",
254 "Sublime Text",
255 "Atom",
256 "TextMate",
257 "Emacs",
258 "Cursor",
259 "None",
260 ];
261}
262
263#[skip_serializing_none]
264#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
265pub struct TitleBarSettingsContent {
266 /// Whether to show the branch icon beside branch switcher in the title bar.
267 ///
268 /// Default: false
269 pub show_branch_icon: Option<bool>,
270 /// Whether to show onboarding banners in the title bar.
271 ///
272 /// Default: true
273 pub show_onboarding_banner: Option<bool>,
274 /// Whether to show user avatar in the title bar.
275 ///
276 /// Default: true
277 pub show_user_picture: Option<bool>,
278 /// Whether to show the branch name button in the titlebar.
279 ///
280 /// Default: true
281 pub show_branch_name: Option<bool>,
282 /// Whether to show the project host and name in the titlebar.
283 ///
284 /// Default: true
285 pub show_project_items: Option<bool>,
286 /// Whether to show the sign in button in the title bar.
287 ///
288 /// Default: true
289 pub show_sign_in: Option<bool>,
290 /// Whether to show the menus in the title bar.
291 ///
292 /// Default: false
293 pub show_menus: Option<bool>,
294}
295
296/// Configuration of audio in Zed.
297#[skip_serializing_none]
298#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
299pub struct AudioSettingsContent {
300 /// Opt into the new audio system.
301 ///
302 /// You need to rejoin a call for this setting to apply
303 #[serde(rename = "experimental.rodio_audio")]
304 pub rodio_audio: Option<bool>, // default is false
305 /// Requires 'rodio_audio: true'
306 ///
307 /// Automatically increase or decrease you microphone's volume. This affects how
308 /// loud you sound to others.
309 ///
310 /// Recommended: off (default)
311 /// Microphones are too quite in zed, until everyone is on experimental
312 /// audio and has auto speaker volume on this will make you very loud
313 /// compared to other speakers.
314 #[serde(rename = "experimental.auto_microphone_volume")]
315 pub auto_microphone_volume: Option<bool>,
316 /// Requires 'rodio_audio: true'
317 ///
318 /// Automatically increate or decrease the volume of other call members.
319 /// This only affects how things sound for you.
320 #[serde(rename = "experimental.auto_speaker_volume")]
321 pub auto_speaker_volume: Option<bool>,
322 /// Requires 'rodio_audio: true'
323 ///
324 /// Remove background noises. Works great for typing, cars, dogs, AC. Does
325 /// not work well on music.
326 #[serde(rename = "experimental.denoise")]
327 pub denoise: Option<bool>,
328 /// Requires 'rodio_audio: true'
329 ///
330 /// Use audio parameters compatible with the previous versions of
331 /// experimental audio and non-experimental audio. When this is false you
332 /// will sound strange to anyone not on the latest experimental audio. In
333 /// the future we will migrate by setting this to false
334 ///
335 /// You need to rejoin a call for this setting to apply
336 #[serde(rename = "experimental.legacy_audio_compatible")]
337 pub legacy_audio_compatible: Option<bool>,
338}
339
340/// Control what info is collected by Zed.
341#[skip_serializing_none]
342#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Debug, MergeFrom)]
343pub struct TelemetrySettingsContent {
344 /// Send debug info like crash reports.
345 ///
346 /// Default: true
347 pub diagnostics: Option<bool>,
348 /// Send anonymized usage data like what languages you're using Zed with.
349 ///
350 /// Default: true
351 pub metrics: Option<bool>,
352}
353
354impl Default for TelemetrySettingsContent {
355 fn default() -> Self {
356 Self {
357 diagnostics: Some(true),
358 metrics: Some(true),
359 }
360 }
361}
362
363#[skip_serializing_none]
364#[derive(Default, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Clone, MergeFrom)]
365pub struct DebuggerSettingsContent {
366 /// Determines the stepping granularity.
367 ///
368 /// Default: line
369 pub stepping_granularity: Option<SteppingGranularity>,
370 /// Whether the breakpoints should be reused across Zed sessions.
371 ///
372 /// Default: true
373 pub save_breakpoints: Option<bool>,
374 /// Whether to show the debug button in the status bar.
375 ///
376 /// Default: true
377 pub button: Option<bool>,
378 /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
379 ///
380 /// Default: 2000ms
381 pub timeout: Option<u64>,
382 /// Whether to log messages between active debug adapters and Zed
383 ///
384 /// Default: true
385 pub log_dap_communications: Option<bool>,
386 /// Whether to format dap messages in when adding them to debug adapter logger
387 ///
388 /// Default: true
389 pub format_dap_log_messages: Option<bool>,
390 /// The dock position of the debug panel
391 ///
392 /// Default: Bottom
393 pub dock: Option<DockPosition>,
394}
395
396/// The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
397#[derive(
398 PartialEq,
399 Eq,
400 Debug,
401 Hash,
402 Clone,
403 Copy,
404 Deserialize,
405 Serialize,
406 JsonSchema,
407 MergeFrom,
408 strum::VariantArray,
409 strum::VariantNames,
410)]
411#[serde(rename_all = "snake_case")]
412pub enum SteppingGranularity {
413 /// The step should allow the program to run until the current statement has finished executing.
414 /// The meaning of a statement is determined by the adapter and it may be considered equivalent to a line.
415 /// For example 'for(int i = 0; i < 10; i++)' could be considered to have 3 statements 'int i = 0', 'i < 10', and 'i++'.
416 Statement,
417 /// The step should allow the program to run until the current source line has executed.
418 Line,
419 /// The step should allow one instruction to execute (e.g. one x86 instruction).
420 Instruction,
421}
422
423#[derive(
424 Copy,
425 Clone,
426 Debug,
427 Serialize,
428 Deserialize,
429 JsonSchema,
430 MergeFrom,
431 PartialEq,
432 Eq,
433 strum::VariantArray,
434 strum::VariantNames,
435)]
436#[serde(rename_all = "snake_case")]
437pub enum DockPosition {
438 Left,
439 Bottom,
440 Right,
441}
442
443/// Settings for slash commands.
444#[skip_serializing_none]
445#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, MergeFrom, PartialEq, Eq)]
446pub struct SlashCommandSettings {
447 /// Settings for the `/cargo-workspace` slash command.
448 pub cargo_workspace: Option<CargoWorkspaceCommandSettings>,
449}
450
451/// Settings for the `/cargo-workspace` slash command.
452#[skip_serializing_none]
453#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, MergeFrom, PartialEq, Eq)]
454pub struct CargoWorkspaceCommandSettings {
455 /// Whether `/cargo-workspace` is enabled.
456 pub enabled: Option<bool>,
457}
458
459/// Configuration of voice calls in Zed.
460#[skip_serializing_none]
461#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
462pub struct CallSettingsContent {
463 /// Whether the microphone should be muted when joining a channel or a call.
464 ///
465 /// Default: false
466 pub mute_on_join: Option<bool>,
467
468 /// Whether your current project should be shared when joining an empty channel.
469 ///
470 /// Default: false
471 pub share_on_join: Option<bool>,
472}
473
474#[skip_serializing_none]
475#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
476pub struct GitPanelSettingsContent {
477 /// Whether to show the panel button in the status bar.
478 ///
479 /// Default: true
480 pub button: Option<bool>,
481 /// Where to dock the panel.
482 ///
483 /// Default: left
484 pub dock: Option<DockPosition>,
485 /// Default width of the panel in pixels.
486 ///
487 /// Default: 360
488 pub default_width: Option<f32>,
489 /// How entry statuses are displayed.
490 ///
491 /// Default: icon
492 pub status_style: Option<StatusStyle>,
493 /// How and when the scrollbar should be displayed.
494 ///
495 /// Default: inherits editor scrollbar settings
496 pub scrollbar: Option<ScrollbarSettings>,
497
498 /// What the default branch name should be when
499 /// `init.defaultBranch` is not set in git
500 ///
501 /// Default: main
502 pub fallback_branch_name: Option<String>,
503
504 /// Whether to sort entries in the panel by path
505 /// or by status (the default).
506 ///
507 /// Default: false
508 pub sort_by_path: Option<bool>,
509
510 /// Whether to collapse untracked files in the diff panel.
511 ///
512 /// Default: false
513 pub collapse_untracked_diff: Option<bool>,
514}
515
516#[derive(
517 Default,
518 Copy,
519 Clone,
520 Debug,
521 Serialize,
522 Deserialize,
523 JsonSchema,
524 MergeFrom,
525 PartialEq,
526 Eq,
527 strum::VariantArray,
528 strum::VariantNames,
529)]
530#[serde(rename_all = "snake_case")]
531pub enum StatusStyle {
532 #[default]
533 Icon,
534 LabelColor,
535}
536
537#[skip_serializing_none]
538#[derive(
539 Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
540)]
541pub struct ScrollbarSettings {
542 pub show: Option<ShowScrollbar>,
543}
544
545#[skip_serializing_none]
546#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
547pub struct NotificationPanelSettingsContent {
548 /// Whether to show the panel button in the status bar.
549 ///
550 /// Default: true
551 pub button: Option<bool>,
552 /// Where to dock the panel.
553 ///
554 /// Default: right
555 pub dock: Option<DockPosition>,
556 /// Default width of the panel in pixels.
557 ///
558 /// Default: 300
559 pub default_width: Option<f32>,
560}
561
562#[skip_serializing_none]
563#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
564pub struct PanelSettingsContent {
565 /// Whether to show the panel button in the status bar.
566 ///
567 /// Default: true
568 pub button: Option<bool>,
569 /// Where to dock the panel.
570 ///
571 /// Default: left
572 pub dock: Option<DockPosition>,
573 /// Default width of the panel in pixels.
574 ///
575 /// Default: 240
576 pub default_width: Option<f32>,
577}
578
579#[skip_serializing_none]
580#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
581pub struct MessageEditorSettings {
582 /// Whether to automatically replace emoji shortcodes with emoji characters.
583 /// For example: typing `:wave:` gets replaced with `👋`.
584 ///
585 /// Default: false
586 pub auto_replace_emoji_shortcode: Option<bool>,
587}
588
589#[skip_serializing_none]
590#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
591pub struct FileFinderSettingsContent {
592 /// Whether to show file icons in the file finder.
593 ///
594 /// Default: true
595 pub file_icons: Option<bool>,
596 /// Determines how much space the file finder can take up in relation to the available window width.
597 ///
598 /// Default: small
599 pub modal_max_width: Option<FileFinderWidthContent>,
600 /// Determines whether the file finder should skip focus for the active file in search results.
601 ///
602 /// Default: true
603 pub skip_focus_for_active_in_search: Option<bool>,
604 /// Determines whether to show the git status in the file finder
605 ///
606 /// Default: true
607 pub git_status: Option<bool>,
608 /// Whether to use gitignored files when searching.
609 /// Only the file Zed had indexed will be used, not necessary all the gitignored files.
610 ///
611 /// Can accept 3 values:
612 /// * `Some(true)`: Use all gitignored files
613 /// * `Some(false)`: Use only the files Zed had indexed
614 /// * `None`: Be smart and search for ignored when called from a gitignored worktree
615 ///
616 /// Default: None
617 /// todo() -> Change this type to an enum
618 pub include_ignored: Option<bool>,
619}
620
621#[derive(
622 Debug,
623 PartialEq,
624 Eq,
625 Clone,
626 Copy,
627 Default,
628 Serialize,
629 Deserialize,
630 JsonSchema,
631 MergeFrom,
632 strum::VariantArray,
633 strum::VariantNames,
634)]
635#[serde(rename_all = "lowercase")]
636pub enum FileFinderWidthContent {
637 #[default]
638 Small,
639 Medium,
640 Large,
641 XLarge,
642 Full,
643}
644
645#[skip_serializing_none]
646#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug, JsonSchema, MergeFrom)]
647pub struct VimSettingsContent {
648 pub default_mode: Option<ModeContent>,
649 pub toggle_relative_line_numbers: Option<bool>,
650 pub use_system_clipboard: Option<UseSystemClipboard>,
651 pub use_smartcase_find: Option<bool>,
652 pub custom_digraphs: Option<HashMap<String, Arc<str>>>,
653 pub highlight_on_yank_duration: Option<u64>,
654 pub cursor_shape: Option<CursorShapeSettings>,
655}
656
657#[derive(Copy, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Debug)]
658#[serde(rename_all = "snake_case")]
659pub enum ModeContent {
660 #[default]
661 Normal,
662 Insert,
663}
664
665/// Controls when to use system clipboard.
666#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
667#[serde(rename_all = "snake_case")]
668pub enum UseSystemClipboard {
669 /// Don't use system clipboard.
670 Never,
671 /// Use system clipboard.
672 Always,
673 /// Use system clipboard for yank operations.
674 OnYank,
675}
676
677/// The settings for cursor shape.
678#[skip_serializing_none]
679#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
680pub struct CursorShapeSettings {
681 /// Cursor shape for the normal mode.
682 ///
683 /// Default: block
684 pub normal: Option<CursorShape>,
685 /// Cursor shape for the replace mode.
686 ///
687 /// Default: underline
688 pub replace: Option<CursorShape>,
689 /// Cursor shape for the visual mode.
690 ///
691 /// Default: block
692 pub visual: Option<CursorShape>,
693 /// Cursor shape for the insert mode.
694 ///
695 /// The default value follows the primary cursor_shape.
696 pub insert: Option<CursorShape>,
697}
698
699/// Settings specific to journaling
700#[skip_serializing_none]
701#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
702pub struct JournalSettingsContent {
703 /// The path of the directory where journal entries are stored.
704 ///
705 /// Default: `~`
706 pub path: Option<String>,
707 /// What format to display the hours in.
708 ///
709 /// Default: hour12
710 pub hour_format: Option<HourFormat>,
711}
712
713#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
714#[serde(rename_all = "snake_case")]
715pub enum HourFormat {
716 #[default]
717 Hour12,
718 Hour24,
719}
720
721#[skip_serializing_none]
722#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
723pub struct OutlinePanelSettingsContent {
724 /// Whether to show the outline panel button in the status bar.
725 ///
726 /// Default: true
727 pub button: Option<bool>,
728 /// Customize default width (in pixels) taken by outline panel
729 ///
730 /// Default: 240
731 pub default_width: Option<f32>,
732 /// The position of outline panel
733 ///
734 /// Default: left
735 pub dock: Option<DockSide>,
736 /// Whether to show file icons in the outline panel.
737 ///
738 /// Default: true
739 pub file_icons: Option<bool>,
740 /// Whether to show folder icons or chevrons for directories in the outline panel.
741 ///
742 /// Default: true
743 pub folder_icons: Option<bool>,
744 /// Whether to show the git status in the outline panel.
745 ///
746 /// Default: true
747 pub git_status: Option<bool>,
748 /// Amount of indentation (in pixels) for nested items.
749 ///
750 /// Default: 20
751 pub indent_size: Option<f32>,
752 /// Whether to reveal it in the outline panel automatically,
753 /// when a corresponding project entry becomes active.
754 /// Gitignored entries are never auto revealed.
755 ///
756 /// Default: true
757 pub auto_reveal_entries: Option<bool>,
758 /// Whether to fold directories automatically
759 /// when directory has only one directory inside.
760 ///
761 /// Default: true
762 pub auto_fold_dirs: Option<bool>,
763 /// Settings related to indent guides in the outline panel.
764 pub indent_guides: Option<IndentGuidesSettingsContent>,
765 /// Scrollbar-related settings
766 pub scrollbar: Option<ScrollbarSettingsContent>,
767 /// Default depth to expand outline items in the current file.
768 /// The default depth to which outline entries are expanded on reveal.
769 /// - Set to 0 to collapse all items that have children
770 /// - Set to 1 or higher to collapse items at that depth or deeper
771 ///
772 /// Default: 100
773 pub expand_outlines_with_depth: Option<usize>,
774}
775
776#[derive(
777 Clone,
778 Copy,
779 Debug,
780 PartialEq,
781 Eq,
782 Serialize,
783 Deserialize,
784 JsonSchema,
785 MergeFrom,
786 strum::VariantArray,
787 strum::VariantNames,
788)]
789#[serde(rename_all = "snake_case")]
790pub enum DockSide {
791 Left,
792 Right,
793}
794
795#[derive(
796 Copy,
797 Clone,
798 Debug,
799 PartialEq,
800 Eq,
801 Deserialize,
802 Serialize,
803 JsonSchema,
804 MergeFrom,
805 strum::VariantArray,
806 strum::VariantNames,
807)]
808#[serde(rename_all = "snake_case")]
809pub enum ShowIndentGuides {
810 Always,
811 Never,
812}
813
814#[skip_serializing_none]
815#[derive(
816 Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq, Default,
817)]
818pub struct IndentGuidesSettingsContent {
819 /// When to show the scrollbar in the outline panel.
820 pub show: Option<ShowIndentGuides>,
821}
822
823#[derive(Clone, Copy, Default, PartialEq, Debug, JsonSchema, MergeFrom, Deserialize, Serialize)]
824#[serde(rename_all = "snake_case")]
825pub enum LineIndicatorFormat {
826 Short,
827 #[default]
828 Long,
829}
830
831/// The settings for the image viewer.
832#[skip_serializing_none]
833#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Default, PartialEq)]
834pub struct ImageViewerSettingsContent {
835 /// The unit to use for displaying image file sizes.
836 ///
837 /// Default: "binary"
838 pub unit: Option<ImageFileSizeUnit>,
839}
840
841#[skip_serializing_none]
842#[derive(
843 Clone,
844 Copy,
845 Debug,
846 Serialize,
847 Deserialize,
848 JsonSchema,
849 MergeFrom,
850 Default,
851 PartialEq,
852 strum::VariantArray,
853 strum::VariantNames,
854)]
855#[serde(rename_all = "snake_case")]
856pub enum ImageFileSizeUnit {
857 /// Displays file size in binary units (e.g., KiB, MiB).
858 #[default]
859 Binary,
860 /// Displays file size in decimal units (e.g., KB, MB).
861 Decimal,
862}
863
864#[skip_serializing_none]
865#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
866pub struct RemoteSettingsContent {
867 pub ssh_connections: Option<Vec<SshConnection>>,
868 pub wsl_connections: Option<Vec<WslConnection>>,
869 pub read_ssh_config: Option<bool>,
870}
871
872#[skip_serializing_none]
873#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
874pub struct SshConnection {
875 pub host: SharedString,
876 pub username: Option<String>,
877 pub port: Option<u16>,
878 #[serde(default)]
879 pub args: Vec<String>,
880 #[serde(default)]
881 pub projects: collections::BTreeSet<SshProject>,
882 /// Name to use for this server in UI.
883 pub nickname: Option<String>,
884 // By default Zed will download the binary to the host directly.
885 // If this is set to true, Zed will download the binary to your local machine,
886 // and then upload it over the SSH connection. Useful if your SSH server has
887 // limited outbound internet access.
888 pub upload_binary_over_ssh: Option<bool>,
889
890 pub port_forwards: Option<Vec<SshPortForwardOption>>,
891}
892
893#[derive(Clone, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom, Debug)]
894pub struct WslConnection {
895 pub distro_name: SharedString,
896 pub user: Option<String>,
897 #[serde(default)]
898 pub projects: BTreeSet<SshProject>,
899}
900
901#[skip_serializing_none]
902#[derive(
903 Clone, Debug, Default, Serialize, PartialEq, Eq, PartialOrd, Ord, Deserialize, JsonSchema,
904)]
905pub struct SshProject {
906 pub paths: Vec<String>,
907}
908
909#[skip_serializing_none]
910#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema, MergeFrom)]
911pub struct SshPortForwardOption {
912 #[serde(skip_serializing_if = "Option::is_none")]
913 pub local_host: Option<String>,
914 pub local_port: u16,
915 #[serde(skip_serializing_if = "Option::is_none")]
916 pub remote_host: Option<String>,
917 pub remote_port: u16,
918}
919
920/// Settings for configuring REPL display and behavior.
921#[skip_serializing_none]
922#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
923pub struct ReplSettingsContent {
924 /// Maximum number of lines to keep in REPL's scrollback buffer.
925 /// Clamped with [4, 256] range.
926 ///
927 /// Default: 32
928 pub max_lines: Option<usize>,
929 /// Maximum number of columns to keep in REPL's scrollback buffer.
930 /// Clamped with [20, 512] range.
931 ///
932 /// Default: 128
933 pub max_columns: Option<usize>,
934}
935
936#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
937/// An ExtendingVec in the settings can only accumulate new values.
938///
939/// This is useful for things like private files where you only want
940/// to allow new values to be added.
941///
942/// Consider using a HashMap<String, bool> instead of this type
943/// (like auto_install_extensions) so that user settings files can both add
944/// and remove values from the set.
945pub struct ExtendingVec<T>(pub Vec<T>);
946
947impl<T> Into<Vec<T>> for ExtendingVec<T> {
948 fn into(self) -> Vec<T> {
949 self.0
950 }
951}
952impl<T> From<Vec<T>> for ExtendingVec<T> {
953 fn from(vec: Vec<T>) -> Self {
954 ExtendingVec(vec)
955 }
956}
957
958impl<T: Clone> merge_from::MergeFrom for ExtendingVec<T> {
959 fn merge_from(&mut self, other: &Self) {
960 self.0.extend_from_slice(other.0.as_slice());
961 }
962}
963
964/// A SaturatingBool in the settings can only ever be set to true,
965/// later attempts to set it to false will be ignored.
966///
967/// Used by `disable_ai`.
968#[derive(Debug, Default, Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
969pub struct SaturatingBool(pub bool);
970
971impl From<bool> for SaturatingBool {
972 fn from(value: bool) -> Self {
973 SaturatingBool(value)
974 }
975}
976
977impl From<SaturatingBool> for bool {
978 fn from(value: SaturatingBool) -> bool {
979 value.0
980 }
981}
982
983impl merge_from::MergeFrom for SaturatingBool {
984 fn merge_from(&mut self, other: &Self) {
985 self.0 |= other.0
986 }
987}