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