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