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