1mod agent;
2mod editor;
3mod language;
4mod language_model;
5mod project;
6mod terminal;
7mod theme;
8mod workspace;
9
10pub use agent::*;
11pub use editor::*;
12pub use language::*;
13pub use language_model::*;
14pub use project::*;
15pub use terminal::*;
16pub use theme::*;
17pub use workspace::*;
18
19use collections::{HashMap, IndexMap};
20use gpui::{App, SharedString};
21use release_channel::ReleaseChannel;
22use schemars::JsonSchema;
23use serde::{Deserialize, Serialize};
24use serde_with::skip_serializing_none;
25use settings_macros::MergeFrom;
26use std::collections::BTreeSet;
27use std::env;
28use std::sync::Arc;
29pub use util::serde::default_true;
30
31use crate::{ActiveSettingsProfileName, merge_from};
32
33#[skip_serializing_none]
34#[derive(Debug, PartialEq, Default, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
35pub struct SettingsContent {
36 #[serde(flatten)]
37 pub project: ProjectSettingsContent,
38
39 #[serde(flatten)]
40 pub theme: Box<ThemeSettingsContent>,
41
42 #[serde(flatten)]
43 pub extension: ExtensionSettingsContent,
44
45 #[serde(flatten)]
46 pub workspace: WorkspaceSettingsContent,
47
48 #[serde(flatten)]
49 pub editor: EditorSettingsContent,
50
51 #[serde(flatten)]
52 pub remote: RemoteSettingsContent,
53
54 /// Settings related to the file finder.
55 pub file_finder: Option<FileFinderSettingsContent>,
56
57 pub git_panel: Option<GitPanelSettingsContent>,
58
59 pub tabs: Option<ItemSettingsContent>,
60 pub tab_bar: Option<TabBarSettingsContent>,
61
62 pub preview_tabs: Option<PreviewTabsSettingsContent>,
63
64 pub agent: Option<AgentSettingsContent>,
65 pub agent_servers: Option<AllAgentServersSettings>,
66
67 /// Configuration of audio in Zed.
68 pub audio: Option<AudioSettingsContent>,
69
70 /// Whether or not to automatically check for updates.
71 ///
72 /// Default: true
73 pub auto_update: Option<bool>,
74
75 /// This base keymap settings adjusts the default keybindings in Zed to be similar
76 /// to other common code editors. By default, Zed's keymap closely follows VSCode's
77 /// keymap, with minor adjustments, this corresponds to the "VSCode" setting.
78 ///
79 /// Default: VSCode
80 pub base_keymap: Option<BaseKeymapContent>,
81
82 /// Configuration for the collab panel visual settings.
83 pub collaboration_panel: Option<PanelSettingsContent>,
84
85 pub debugger: Option<DebuggerSettingsContent>,
86
87 /// Configuration for Diagnostics-related features.
88 pub diagnostics: Option<DiagnosticsSettingsContent>,
89
90 /// Configuration for Git-related features
91 pub git: Option<GitSettings>,
92
93 /// Common language server settings.
94 pub global_lsp_settings: Option<GlobalLspSettingsContent>,
95
96 /// The settings for the image viewer.
97 pub image_viewer: Option<ImageViewerSettingsContent>,
98
99 pub repl: Option<ReplSettingsContent>,
100
101 /// Whether or not to enable Helix mode.
102 ///
103 /// Default: false
104 pub helix_mode: Option<bool>,
105
106 pub journal: Option<JournalSettingsContent>,
107
108 /// A map of log scopes to the desired log level.
109 /// Useful for filtering out noisy logs or enabling more verbose logging.
110 ///
111 /// Example: {"log": {"client": "warn"}}
112 pub log: Option<HashMap<String, String>>,
113
114 pub line_indicator_format: Option<LineIndicatorFormat>,
115
116 pub language_models: Option<AllLanguageModelSettingsContent>,
117
118 pub outline_panel: Option<OutlinePanelSettingsContent>,
119
120 pub project_panel: Option<ProjectPanelSettingsContent>,
121
122 /// Configuration for the Message Editor
123 pub message_editor: Option<MessageEditorSettings>,
124
125 /// Configuration for Node-related features
126 pub node: Option<NodeBinarySettings>,
127
128 /// Configuration for the Notification Panel
129 pub notification_panel: Option<NotificationPanelSettingsContent>,
130
131 pub proxy: Option<String>,
132
133 /// The URL of the Zed server to connect to.
134 pub server_url: Option<String>,
135
136 /// Configuration for session-related features
137 pub session: Option<SessionSettingsContent>,
138 /// Control what info is collected by Zed.
139 pub telemetry: Option<TelemetrySettingsContent>,
140
141 /// Configuration of the terminal in Zed.
142 pub terminal: Option<TerminalSettingsContent>,
143
144 pub title_bar: Option<TitleBarSettingsContent>,
145
146 /// Whether or not to enable Vim mode.
147 ///
148 /// Default: false
149 pub vim_mode: Option<bool>,
150
151 // Settings related to calls in Zed
152 pub calls: Option<CallSettingsContent>,
153
154 /// Whether to disable all AI features in Zed.
155 ///
156 /// Default: false
157 pub disable_ai: Option<SaturatingBool>,
158
159 /// Settings related to Vim mode in Zed.
160 pub vim: Option<VimSettingsContent>,
161}
162
163impl SettingsContent {
164 pub fn languages_mut(&mut self) -> &mut HashMap<SharedString, LanguageSettingsContent> {
165 &mut self.project.all_languages.languages.0
166 }
167}
168
169#[skip_serializing_none]
170#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
171pub struct UserSettingsContent {
172 #[serde(flatten)]
173 pub content: Box<SettingsContent>,
174
175 pub dev: Option<Box<SettingsContent>>,
176 pub nightly: Option<Box<SettingsContent>>,
177 pub preview: Option<Box<SettingsContent>>,
178 pub stable: Option<Box<SettingsContent>>,
179
180 pub macos: Option<Box<SettingsContent>>,
181 pub windows: Option<Box<SettingsContent>>,
182 pub linux: Option<Box<SettingsContent>>,
183
184 #[serde(default)]
185 pub profiles: IndexMap<String, SettingsContent>,
186}
187
188pub struct ExtensionsSettingsContent {
189 pub all_languages: AllLanguageSettingsContent,
190}
191
192impl UserSettingsContent {
193 pub fn for_release_channel(&self) -> Option<&SettingsContent> {
194 match *release_channel::RELEASE_CHANNEL {
195 ReleaseChannel::Dev => self.dev.as_deref(),
196 ReleaseChannel::Nightly => self.nightly.as_deref(),
197 ReleaseChannel::Preview => self.preview.as_deref(),
198 ReleaseChannel::Stable => self.stable.as_deref(),
199 }
200 }
201
202 pub fn for_os(&self) -> Option<&SettingsContent> {
203 match env::consts::OS {
204 "macos" => self.macos.as_deref(),
205 "linux" => self.linux.as_deref(),
206 "windows" => self.windows.as_deref(),
207 _ => None,
208 }
209 }
210
211 pub fn for_profile(&self, cx: &App) -> Option<&SettingsContent> {
212 let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() else {
213 return None;
214 };
215 self.profiles.get(&active_profile.0)
216 }
217}
218
219/// Base key bindings scheme. Base keymaps can be overridden with user keymaps.
220///
221/// Default: VSCode
222#[derive(
223 Copy,
224 Clone,
225 Debug,
226 Serialize,
227 Deserialize,
228 JsonSchema,
229 MergeFrom,
230 PartialEq,
231 Eq,
232 Default,
233 strum::VariantArray,
234 strum::VariantNames,
235)]
236pub enum BaseKeymapContent {
237 #[default]
238 VSCode,
239 JetBrains,
240 SublimeText,
241 Atom,
242 TextMate,
243 Emacs,
244 Cursor,
245 None,
246}
247
248#[skip_serializing_none]
249#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
250pub struct TitleBarSettingsContent {
251 /// Whether to show the branch icon beside branch switcher in the title bar.
252 ///
253 /// Default: false
254 pub show_branch_icon: Option<bool>,
255 /// Whether to show onboarding banners in the title bar.
256 ///
257 /// Default: true
258 pub show_onboarding_banner: Option<bool>,
259 /// Whether to show user avatar in the title bar.
260 ///
261 /// Default: true
262 pub show_user_picture: Option<bool>,
263 /// Whether to show the branch name button in the titlebar.
264 ///
265 /// Default: true
266 pub show_branch_name: Option<bool>,
267 /// Whether to show the project host and name in the titlebar.
268 ///
269 /// Default: true
270 pub show_project_items: Option<bool>,
271 /// Whether to show the sign in button in the title bar.
272 ///
273 /// Default: true
274 pub show_sign_in: Option<bool>,
275 /// Whether to show the menus in the title bar.
276 ///
277 /// Default: false
278 pub show_menus: Option<bool>,
279}
280
281/// Configuration of audio in Zed.
282#[skip_serializing_none]
283#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
284pub struct AudioSettingsContent {
285 /// Opt into the new audio system.
286 ///
287 /// You need to rejoin a call for this setting to apply
288 #[serde(rename = "experimental.rodio_audio")]
289 pub rodio_audio: Option<bool>, // default is false
290 /// Requires 'rodio_audio: true'
291 ///
292 /// Automatically increase or decrease you microphone's volume. This affects how
293 /// loud you sound to others.
294 ///
295 /// Recommended: off (default)
296 /// Microphones are too quite in zed, until everyone is on experimental
297 /// audio and has auto speaker volume on this will make you very loud
298 /// compared to other speakers.
299 #[serde(rename = "experimental.auto_microphone_volume")]
300 pub auto_microphone_volume: Option<bool>,
301 /// Requires 'rodio_audio: true'
302 ///
303 /// Automatically increate or decrease the volume of other call members.
304 /// This only affects how things sound for you.
305 #[serde(rename = "experimental.auto_speaker_volume")]
306 pub auto_speaker_volume: Option<bool>,
307 /// Requires 'rodio_audio: true'
308 ///
309 /// Remove background noises. Works great for typing, cars, dogs, AC. Does
310 /// not work well on music.
311 #[serde(rename = "experimental.denoise")]
312 pub denoise: Option<bool>,
313 /// Requires 'rodio_audio: true'
314 ///
315 /// Use audio parameters compatible with the previous versions of
316 /// experimental audio and non-experimental audio. When this is false you
317 /// will sound strange to anyone not on the latest experimental audio. In
318 /// the future we will migrate by setting this to false
319 ///
320 /// You need to rejoin a call for this setting to apply
321 #[serde(rename = "experimental.legacy_audio_compatible")]
322 pub legacy_audio_compatible: Option<bool>,
323}
324
325/// Control what info is collected by Zed.
326#[skip_serializing_none]
327#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Debug, MergeFrom)]
328pub struct TelemetrySettingsContent {
329 /// Send debug info like crash reports.
330 ///
331 /// Default: true
332 pub diagnostics: Option<bool>,
333 /// Send anonymized usage data like what languages you're using Zed with.
334 ///
335 /// Default: true
336 pub metrics: Option<bool>,
337}
338
339impl Default for TelemetrySettingsContent {
340 fn default() -> Self {
341 Self {
342 diagnostics: Some(true),
343 metrics: Some(true),
344 }
345 }
346}
347
348#[skip_serializing_none]
349#[derive(Default, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Clone, MergeFrom)]
350pub struct DebuggerSettingsContent {
351 /// Determines the stepping granularity.
352 ///
353 /// Default: line
354 pub stepping_granularity: Option<SteppingGranularity>,
355 /// Whether the breakpoints should be reused across Zed sessions.
356 ///
357 /// Default: true
358 pub save_breakpoints: Option<bool>,
359 /// Whether to show the debug button in the status bar.
360 ///
361 /// Default: true
362 pub button: Option<bool>,
363 /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
364 ///
365 /// Default: 2000ms
366 pub timeout: Option<u64>,
367 /// Whether to log messages between active debug adapters and Zed
368 ///
369 /// Default: true
370 pub log_dap_communications: Option<bool>,
371 /// Whether to format dap messages in when adding them to debug adapter logger
372 ///
373 /// Default: true
374 pub format_dap_log_messages: Option<bool>,
375 /// The dock position of the debug panel
376 ///
377 /// Default: Bottom
378 pub dock: Option<DockPosition>,
379}
380
381/// The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
382#[derive(
383 PartialEq, Eq, Debug, Hash, Clone, Copy, Deserialize, Serialize, JsonSchema, MergeFrom,
384)]
385#[serde(rename_all = "snake_case")]
386pub enum SteppingGranularity {
387 /// The step should allow the program to run until the current statement has finished executing.
388 /// The meaning of a statement is determined by the adapter and it may be considered equivalent to a line.
389 /// For example 'for(int i = 0; i < 10; i++)' could be considered to have 3 statements 'int i = 0', 'i < 10', and 'i++'.
390 Statement,
391 /// The step should allow the program to run until the current source line has executed.
392 Line,
393 /// The step should allow one instruction to execute (e.g. one x86 instruction).
394 Instruction,
395}
396
397#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
398#[serde(rename_all = "snake_case")]
399pub enum DockPosition {
400 Left,
401 Bottom,
402 Right,
403}
404
405/// Settings for slash commands.
406#[skip_serializing_none]
407#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, MergeFrom, PartialEq, Eq)]
408pub struct SlashCommandSettings {
409 /// Settings for the `/cargo-workspace` slash command.
410 pub cargo_workspace: Option<CargoWorkspaceCommandSettings>,
411}
412
413/// Settings for the `/cargo-workspace` slash command.
414#[skip_serializing_none]
415#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, MergeFrom, PartialEq, Eq)]
416pub struct CargoWorkspaceCommandSettings {
417 /// Whether `/cargo-workspace` is enabled.
418 pub enabled: Option<bool>,
419}
420
421/// Configuration of voice calls in Zed.
422#[skip_serializing_none]
423#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
424pub struct CallSettingsContent {
425 /// Whether the microphone should be muted when joining a channel or a call.
426 ///
427 /// Default: false
428 pub mute_on_join: Option<bool>,
429
430 /// Whether your current project should be shared when joining an empty channel.
431 ///
432 /// Default: false
433 pub share_on_join: Option<bool>,
434}
435
436#[skip_serializing_none]
437#[derive(Deserialize, Serialize, PartialEq, Debug, Default, Clone, JsonSchema, MergeFrom)]
438pub struct ExtensionSettingsContent {
439 /// The extensions that should be automatically installed by Zed.
440 ///
441 /// This is used to make functionality provided by extensions (e.g., language support)
442 /// available out-of-the-box.
443 ///
444 /// Default: { "html": true }
445 #[serde(default)]
446 pub auto_install_extensions: HashMap<Arc<str>, bool>,
447 #[serde(default)]
448 pub auto_update_extensions: HashMap<Arc<str>, 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, PartialEq, Eq, Clone, Copy, Default, Serialize, Deserialize, JsonSchema, MergeFrom,
587)]
588#[serde(rename_all = "lowercase")]
589pub enum FileFinderWidthContent {
590 #[default]
591 Small,
592 Medium,
593 Large,
594 XLarge,
595 Full,
596}
597
598#[skip_serializing_none]
599#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug, JsonSchema, MergeFrom)]
600pub struct VimSettingsContent {
601 pub default_mode: Option<ModeContent>,
602 pub toggle_relative_line_numbers: Option<bool>,
603 pub use_system_clipboard: Option<UseSystemClipboard>,
604 pub use_smartcase_find: Option<bool>,
605 pub custom_digraphs: Option<HashMap<String, Arc<str>>>,
606 pub highlight_on_yank_duration: Option<u64>,
607 pub cursor_shape: Option<CursorShapeSettings>,
608}
609
610#[derive(Copy, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Debug)]
611#[serde(rename_all = "snake_case")]
612pub enum ModeContent {
613 #[default]
614 Normal,
615 Insert,
616}
617
618/// Controls when to use system clipboard.
619#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
620#[serde(rename_all = "snake_case")]
621pub enum UseSystemClipboard {
622 /// Don't use system clipboard.
623 Never,
624 /// Use system clipboard.
625 Always,
626 /// Use system clipboard for yank operations.
627 OnYank,
628}
629
630/// The settings for cursor shape.
631#[skip_serializing_none]
632#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
633pub struct CursorShapeSettings {
634 /// Cursor shape for the normal mode.
635 ///
636 /// Default: block
637 pub normal: Option<CursorShape>,
638 /// Cursor shape for the replace mode.
639 ///
640 /// Default: underline
641 pub replace: Option<CursorShape>,
642 /// Cursor shape for the visual mode.
643 ///
644 /// Default: block
645 pub visual: Option<CursorShape>,
646 /// Cursor shape for the insert mode.
647 ///
648 /// The default value follows the primary cursor_shape.
649 pub insert: Option<CursorShape>,
650}
651
652/// Settings specific to journaling
653#[skip_serializing_none]
654#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
655pub struct JournalSettingsContent {
656 /// The path of the directory where journal entries are stored.
657 ///
658 /// Default: `~`
659 pub path: Option<String>,
660 /// What format to display the hours in.
661 ///
662 /// Default: hour12
663 pub hour_format: Option<HourFormat>,
664}
665
666#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
667#[serde(rename_all = "snake_case")]
668pub enum HourFormat {
669 #[default]
670 Hour12,
671 Hour24,
672}
673
674#[skip_serializing_none]
675#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
676pub struct OutlinePanelSettingsContent {
677 /// Whether to show the outline panel button in the status bar.
678 ///
679 /// Default: true
680 pub button: Option<bool>,
681 /// Customize default width (in pixels) taken by outline panel
682 ///
683 /// Default: 240
684 pub default_width: Option<f32>,
685 /// The position of outline panel
686 ///
687 /// Default: left
688 pub dock: Option<DockSide>,
689 /// Whether to show file icons in the outline panel.
690 ///
691 /// Default: true
692 pub file_icons: Option<bool>,
693 /// Whether to show folder icons or chevrons for directories in the outline panel.
694 ///
695 /// Default: true
696 pub folder_icons: Option<bool>,
697 /// Whether to show the git status in the outline panel.
698 ///
699 /// Default: true
700 pub git_status: Option<bool>,
701 /// Amount of indentation (in pixels) for nested items.
702 ///
703 /// Default: 20
704 pub indent_size: Option<f32>,
705 /// Whether to reveal it in the outline panel automatically,
706 /// when a corresponding project entry becomes active.
707 /// Gitignored entries are never auto revealed.
708 ///
709 /// Default: true
710 pub auto_reveal_entries: Option<bool>,
711 /// Whether to fold directories automatically
712 /// when directory has only one directory inside.
713 ///
714 /// Default: true
715 pub auto_fold_dirs: Option<bool>,
716 /// Settings related to indent guides in the outline panel.
717 pub indent_guides: Option<IndentGuidesSettingsContent>,
718 /// Scrollbar-related settings
719 pub scrollbar: Option<ScrollbarSettingsContent>,
720 /// Default depth to expand outline items in the current file.
721 /// The default depth to which outline entries are expanded on reveal.
722 /// - Set to 0 to collapse all items that have children
723 /// - Set to 1 or higher to collapse items at that depth or deeper
724 ///
725 /// Default: 100
726 pub expand_outlines_with_depth: Option<usize>,
727}
728
729#[derive(
730 Clone,
731 Copy,
732 Debug,
733 PartialEq,
734 Eq,
735 Serialize,
736 Deserialize,
737 JsonSchema,
738 MergeFrom,
739 strum::VariantArray,
740 strum::VariantNames,
741)]
742#[serde(rename_all = "snake_case")]
743pub enum DockSide {
744 Left,
745 Right,
746}
747
748#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, JsonSchema, MergeFrom)]
749#[serde(rename_all = "snake_case")]
750pub enum ShowIndentGuides {
751 Always,
752 Never,
753}
754
755#[skip_serializing_none]
756#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
757pub struct IndentGuidesSettingsContent {
758 /// When to show the scrollbar in the outline panel.
759 pub show: Option<ShowIndentGuides>,
760}
761
762#[derive(Clone, Copy, Default, PartialEq, Debug, JsonSchema, MergeFrom, Deserialize, Serialize)]
763#[serde(rename_all = "snake_case")]
764pub enum LineIndicatorFormat {
765 Short,
766 #[default]
767 Long,
768}
769
770/// The settings for the image viewer.
771#[skip_serializing_none]
772#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Default, PartialEq)]
773pub struct ImageViewerSettingsContent {
774 /// The unit to use for displaying image file sizes.
775 ///
776 /// Default: "binary"
777 pub unit: Option<ImageFileSizeUnit>,
778}
779
780#[skip_serializing_none]
781#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Default, PartialEq)]
782#[serde(rename_all = "snake_case")]
783pub enum ImageFileSizeUnit {
784 /// Displays file size in binary units (e.g., KiB, MiB).
785 #[default]
786 Binary,
787 /// Displays file size in decimal units (e.g., KB, MB).
788 Decimal,
789}
790
791#[skip_serializing_none]
792#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
793pub struct RemoteSettingsContent {
794 pub ssh_connections: Option<Vec<SshConnection>>,
795 pub wsl_connections: Option<Vec<WslConnection>>,
796 pub read_ssh_config: Option<bool>,
797}
798
799#[skip_serializing_none]
800#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
801pub struct SshConnection {
802 pub host: SharedString,
803 pub username: Option<String>,
804 pub port: Option<u16>,
805 #[serde(default)]
806 pub args: Vec<String>,
807 #[serde(default)]
808 pub projects: collections::BTreeSet<SshProject>,
809 /// Name to use for this server in UI.
810 pub nickname: Option<String>,
811 // By default Zed will download the binary to the host directly.
812 // If this is set to true, Zed will download the binary to your local machine,
813 // and then upload it over the SSH connection. Useful if your SSH server has
814 // limited outbound internet access.
815 pub upload_binary_over_ssh: Option<bool>,
816
817 pub port_forwards: Option<Vec<SshPortForwardOption>>,
818}
819
820#[derive(Clone, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom, Debug)]
821pub struct WslConnection {
822 pub distro_name: SharedString,
823 pub user: Option<String>,
824 #[serde(default)]
825 pub projects: BTreeSet<SshProject>,
826}
827
828#[skip_serializing_none]
829#[derive(
830 Clone, Debug, Default, Serialize, PartialEq, Eq, PartialOrd, Ord, Deserialize, JsonSchema,
831)]
832pub struct SshProject {
833 pub paths: Vec<String>,
834}
835
836#[skip_serializing_none]
837#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema, MergeFrom)]
838pub struct SshPortForwardOption {
839 #[serde(skip_serializing_if = "Option::is_none")]
840 pub local_host: Option<String>,
841 pub local_port: u16,
842 #[serde(skip_serializing_if = "Option::is_none")]
843 pub remote_host: Option<String>,
844 pub remote_port: u16,
845}
846
847/// Settings for configuring REPL display and behavior.
848#[skip_serializing_none]
849#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
850pub struct ReplSettingsContent {
851 /// Maximum number of lines to keep in REPL's scrollback buffer.
852 /// Clamped with [4, 256] range.
853 ///
854 /// Default: 32
855 pub max_lines: Option<usize>,
856 /// Maximum number of columns to keep in REPL's scrollback buffer.
857 /// Clamped with [20, 512] range.
858 ///
859 /// Default: 128
860 pub max_columns: Option<usize>,
861}
862
863#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
864/// An ExtendingVec in the settings can only accumulate new values.
865///
866/// This is useful for things like private files where you only want
867/// to allow new values to be added.
868///
869/// Consider using a HashMap<String, bool> instead of this type
870/// (like auto_install_extensions) so that user settings files can both add
871/// and remove values from the set.
872pub struct ExtendingVec<T>(pub Vec<T>);
873
874impl<T> Into<Vec<T>> for ExtendingVec<T> {
875 fn into(self) -> Vec<T> {
876 self.0
877 }
878}
879impl<T> From<Vec<T>> for ExtendingVec<T> {
880 fn from(vec: Vec<T>) -> Self {
881 ExtendingVec(vec)
882 }
883}
884
885impl<T: Clone> merge_from::MergeFrom for ExtendingVec<T> {
886 fn merge_from(&mut self, other: &Self) {
887 self.0.extend_from_slice(other.0.as_slice());
888 }
889}
890
891/// A SaturatingBool in the settings can only ever be set to true,
892/// later attempts to set it to false will be ignored.
893///
894/// Used by `disable_ai`.
895#[derive(Debug, Default, Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
896pub struct SaturatingBool(pub bool);
897
898impl From<bool> for SaturatingBool {
899 fn from(value: bool) -> Self {
900 SaturatingBool(value)
901 }
902}
903
904impl From<SaturatingBool> for bool {
905 fn from(value: SaturatingBool) -> bool {
906 value.0
907 }
908}
909
910impl merge_from::MergeFrom for SaturatingBool {
911 fn merge_from(&mut self, other: &Self) {
912 self.0 |= other.0
913 }
914}