1mod agent;
2mod editor;
3mod extension;
4mod fallible_options;
5mod language;
6mod language_model;
7pub mod merge_from;
8mod project;
9mod serde_helper;
10mod terminal;
11mod theme;
12mod title_bar;
13mod workspace;
14
15pub use agent::*;
16pub use editor::*;
17pub use extension::*;
18pub use fallible_options::*;
19pub use language::*;
20pub use language_model::*;
21pub use merge_from::MergeFrom as MergeFromTrait;
22pub use project::*;
23use serde::de::DeserializeOwned;
24pub use serde_helper::{
25 serialize_f32_with_two_decimal_places, serialize_optional_f32_with_two_decimal_places,
26};
27use settings_json::parse_json_with_comments;
28pub use terminal::*;
29pub use theme::*;
30pub use title_bar::*;
31pub use workspace::*;
32
33use collections::{HashMap, IndexMap};
34use schemars::JsonSchema;
35use serde::{Deserialize, Serialize};
36use settings_macros::{MergeFrom, with_fallible_options};
37
38/// Defines a settings override struct where each field is
39/// `Option<Box<SettingsContent>>`, along with:
40/// - `OVERRIDE_KEYS`: a `&[&str]` of the field names (the JSON keys)
41/// - `get_by_key(&self, key) -> Option<&SettingsContent>`: accessor by key
42///
43/// The field list is the single source of truth for the override key strings.
44macro_rules! settings_overrides {
45 (
46 $(#[$attr:meta])*
47 pub struct $name:ident { $($field:ident),* $(,)? }
48 ) => {
49 $(#[$attr])*
50 pub struct $name {
51 $(pub $field: Option<Box<SettingsContent>>,)*
52 }
53
54 impl $name {
55 /// The JSON override keys, derived from the field names on this struct.
56 pub const OVERRIDE_KEYS: &[&str] = &[$(stringify!($field)),*];
57
58 /// Look up an override by its JSON key name.
59 pub fn get_by_key(&self, key: &str) -> Option<&SettingsContent> {
60 match key {
61 $(stringify!($field) => self.$field.as_deref(),)*
62 _ => None,
63 }
64 }
65 }
66 }
67}
68use std::collections::BTreeSet;
69use std::sync::Arc;
70pub use util::serde::default_true;
71
72#[derive(Debug, Clone, PartialEq, Eq)]
73pub enum ParseStatus {
74 /// Settings were parsed successfully
75 Success,
76 /// Settings failed to parse
77 Failed { error: String },
78}
79
80#[with_fallible_options]
81#[derive(Debug, PartialEq, Default, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
82pub struct SettingsContent {
83 #[serde(flatten)]
84 pub project: ProjectSettingsContent,
85
86 #[serde(flatten)]
87 pub theme: Box<ThemeSettingsContent>,
88
89 #[serde(flatten)]
90 pub extension: ExtensionSettingsContent,
91
92 #[serde(flatten)]
93 pub workspace: WorkspaceSettingsContent,
94
95 #[serde(flatten)]
96 pub editor: EditorSettingsContent,
97
98 #[serde(flatten)]
99 pub remote: RemoteSettingsContent,
100
101 /// Settings related to the file finder.
102 pub file_finder: Option<FileFinderSettingsContent>,
103
104 pub git_panel: Option<GitPanelSettingsContent>,
105
106 pub tabs: Option<ItemSettingsContent>,
107 pub tab_bar: Option<TabBarSettingsContent>,
108 pub status_bar: Option<StatusBarSettingsContent>,
109
110 pub preview_tabs: Option<PreviewTabsSettingsContent>,
111
112 pub agent: Option<AgentSettingsContent>,
113 pub agent_servers: Option<AllAgentServersSettings>,
114
115 /// Configuration of audio in Zed.
116 pub audio: Option<AudioSettingsContent>,
117
118 /// Whether or not to automatically check for updates.
119 ///
120 /// Default: true
121 pub auto_update: Option<bool>,
122
123 /// This base keymap settings adjusts the default keybindings in Zed to be similar
124 /// to other common code editors. By default, Zed's keymap closely follows VSCode's
125 /// keymap, with minor adjustments, this corresponds to the "VSCode" setting.
126 ///
127 /// Default: VSCode
128 pub base_keymap: Option<BaseKeymapContent>,
129
130 /// Configuration for the collab panel visual settings.
131 pub collaboration_panel: Option<PanelSettingsContent>,
132
133 pub debugger: Option<DebuggerSettingsContent>,
134
135 /// Configuration for Diagnostics-related features.
136 pub diagnostics: Option<DiagnosticsSettingsContent>,
137
138 /// Configuration for Git-related features
139 pub git: Option<GitSettings>,
140
141 /// Common language server settings.
142 pub global_lsp_settings: Option<GlobalLspSettingsContent>,
143
144 /// The settings for the image viewer.
145 pub image_viewer: Option<ImageViewerSettingsContent>,
146
147 pub repl: Option<ReplSettingsContent>,
148
149 /// Whether or not to enable Helix mode.
150 ///
151 /// Default: false
152 pub helix_mode: Option<bool>,
153
154 pub journal: Option<JournalSettingsContent>,
155
156 /// A map of log scopes to the desired log level.
157 /// Useful for filtering out noisy logs or enabling more verbose logging.
158 ///
159 /// Example: {"log": {"client": "warn"}}
160 pub log: Option<HashMap<String, String>>,
161
162 pub line_indicator_format: Option<LineIndicatorFormat>,
163
164 pub language_models: Option<AllLanguageModelSettingsContent>,
165
166 pub outline_panel: Option<OutlinePanelSettingsContent>,
167
168 pub project_panel: Option<ProjectPanelSettingsContent>,
169
170 /// Configuration for the Message Editor
171 pub message_editor: Option<MessageEditorSettings>,
172
173 /// Configuration for Node-related features
174 pub node: Option<NodeBinarySettings>,
175
176 /// Configuration for the Notification Panel
177 pub notification_panel: Option<NotificationPanelSettingsContent>,
178
179 pub proxy: Option<String>,
180
181 /// The URL of the Zed server to connect to.
182 pub server_url: Option<String>,
183
184 /// Configuration for session-related features
185 pub session: Option<SessionSettingsContent>,
186 /// Control what info is collected by Zed.
187 pub telemetry: Option<TelemetrySettingsContent>,
188
189 /// Configuration of the terminal in Zed.
190 pub terminal: Option<TerminalSettingsContent>,
191
192 pub title_bar: Option<TitleBarSettingsContent>,
193
194 /// Whether or not to enable Vim mode.
195 ///
196 /// Default: false
197 pub vim_mode: Option<bool>,
198
199 // Settings related to calls in Zed
200 pub calls: Option<CallSettingsContent>,
201
202 /// Settings for the which-key popup.
203 pub which_key: Option<WhichKeySettingsContent>,
204
205 /// Settings related to Vim mode in Zed.
206 pub vim: Option<VimSettingsContent>,
207
208 /// Number of lines to search for modelines at the beginning and end of files.
209 /// Modelines contain editor directives (e.g., vim/emacs settings) that configure
210 /// the editor behavior for specific files.
211 ///
212 /// Default: 5
213 pub modeline_lines: Option<usize>,
214}
215
216impl SettingsContent {
217 pub fn languages_mut(&mut self) -> &mut HashMap<String, LanguageSettingsContent> {
218 &mut self.project.all_languages.languages.0
219 }
220}
221
222// These impls are there to optimize builds by avoiding monomorphization downstream. Yes, they're repetitive, but using default impls
223// break the optimization, for whatever reason.
224pub trait RootUserSettings: Sized + DeserializeOwned {
225 fn parse_json(json: &str) -> (Option<Self>, ParseStatus);
226 fn parse_json_with_comments(json: &str) -> anyhow::Result<Self>;
227}
228
229impl RootUserSettings for SettingsContent {
230 fn parse_json(json: &str) -> (Option<Self>, ParseStatus) {
231 fallible_options::parse_json(json)
232 }
233 fn parse_json_with_comments(json: &str) -> anyhow::Result<Self> {
234 parse_json_with_comments(json)
235 }
236}
237// Explicit opt-in instead of blanket impl to avoid monomorphizing downstream. Just a hunch though.
238impl RootUserSettings for Option<SettingsContent> {
239 fn parse_json(json: &str) -> (Option<Self>, ParseStatus) {
240 fallible_options::parse_json(json)
241 }
242 fn parse_json_with_comments(json: &str) -> anyhow::Result<Self> {
243 parse_json_with_comments(json)
244 }
245}
246impl RootUserSettings for UserSettingsContent {
247 fn parse_json(json: &str) -> (Option<Self>, ParseStatus) {
248 fallible_options::parse_json(json)
249 }
250 fn parse_json_with_comments(json: &str) -> anyhow::Result<Self> {
251 parse_json_with_comments(json)
252 }
253}
254
255settings_overrides! {
256 #[with_fallible_options]
257 #[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
258 pub struct ReleaseChannelOverrides { dev, nightly, preview, stable }
259}
260
261settings_overrides! {
262 #[with_fallible_options]
263 #[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
264 pub struct PlatformOverrides { macos, linux, windows }
265}
266
267#[with_fallible_options]
268#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
269pub struct UserSettingsContent {
270 #[serde(flatten)]
271 pub content: Box<SettingsContent>,
272
273 #[serde(flatten)]
274 pub release_channel_overrides: ReleaseChannelOverrides,
275
276 #[serde(flatten)]
277 pub platform_overrides: PlatformOverrides,
278
279 #[serde(default)]
280 pub profiles: IndexMap<String, SettingsContent>,
281}
282
283pub struct ExtensionsSettingsContent {
284 pub all_languages: AllLanguageSettingsContent,
285}
286
287/// Base key bindings scheme. Base keymaps can be overridden with user keymaps.
288///
289/// Default: VSCode
290#[derive(
291 Copy,
292 Clone,
293 Debug,
294 Serialize,
295 Deserialize,
296 JsonSchema,
297 MergeFrom,
298 PartialEq,
299 Eq,
300 Default,
301 strum::VariantArray,
302)]
303pub enum BaseKeymapContent {
304 #[default]
305 VSCode,
306 JetBrains,
307 SublimeText,
308 Atom,
309 TextMate,
310 Emacs,
311 Cursor,
312 None,
313}
314
315impl strum::VariantNames for BaseKeymapContent {
316 const VARIANTS: &'static [&'static str] = &[
317 "VSCode",
318 "JetBrains",
319 "Sublime Text",
320 "Atom",
321 "TextMate",
322 "Emacs",
323 "Cursor",
324 "None",
325 ];
326}
327
328/// Configuration of audio in Zed.
329#[with_fallible_options]
330#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
331pub struct AudioSettingsContent {
332 /// Automatically increase or decrease you microphone's volume. This affects how
333 /// loud you sound to others.
334 ///
335 /// Recommended: off (default)
336 /// Microphones are too quite in zed, until everyone is on experimental
337 /// audio and has auto speaker volume on this will make you very loud
338 /// compared to other speakers.
339 #[serde(rename = "experimental.auto_microphone_volume")]
340 pub auto_microphone_volume: Option<bool>,
341 /// Remove background noises. Works great for typing, cars, dogs, AC. Does
342 /// not work well on music.
343 /// Select specific output audio device.
344 #[serde(rename = "experimental.output_audio_device")]
345 pub output_audio_device: Option<AudioOutputDeviceName>,
346 /// Select specific input audio device.
347 #[serde(rename = "experimental.input_audio_device")]
348 pub input_audio_device: Option<AudioInputDeviceName>,
349}
350
351#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
352#[serde(transparent)]
353pub struct AudioOutputDeviceName(pub Option<String>);
354
355impl AsRef<Option<String>> for AudioInputDeviceName {
356 fn as_ref(&self) -> &Option<String> {
357 &self.0
358 }
359}
360
361impl From<Option<String>> for AudioInputDeviceName {
362 fn from(value: Option<String>) -> Self {
363 Self(value)
364 }
365}
366
367#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
368#[serde(transparent)]
369pub struct AudioInputDeviceName(pub Option<String>);
370
371impl AsRef<Option<String>> for AudioOutputDeviceName {
372 fn as_ref(&self) -> &Option<String> {
373 &self.0
374 }
375}
376
377impl From<Option<String>> for AudioOutputDeviceName {
378 fn from(value: Option<String>) -> Self {
379 Self(value)
380 }
381}
382
383/// Control what info is collected by Zed.
384#[with_fallible_options]
385#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Debug, MergeFrom)]
386pub struct TelemetrySettingsContent {
387 /// Send debug info like crash reports.
388 ///
389 /// Default: true
390 pub diagnostics: Option<bool>,
391 /// Send anonymized usage data like what languages you're using Zed with.
392 ///
393 /// Default: true
394 pub metrics: Option<bool>,
395}
396
397impl Default for TelemetrySettingsContent {
398 fn default() -> Self {
399 Self {
400 diagnostics: Some(true),
401 metrics: Some(true),
402 }
403 }
404}
405
406#[with_fallible_options]
407#[derive(Default, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Clone, MergeFrom)]
408pub struct DebuggerSettingsContent {
409 /// Determines the stepping granularity.
410 ///
411 /// Default: line
412 pub stepping_granularity: Option<SteppingGranularity>,
413 /// Whether the breakpoints should be reused across Zed sessions.
414 ///
415 /// Default: true
416 pub save_breakpoints: Option<bool>,
417 /// Whether to show the debug button in the status bar.
418 ///
419 /// Default: true
420 pub button: Option<bool>,
421 /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
422 ///
423 /// Default: 2000ms
424 pub timeout: Option<u64>,
425 /// Whether to log messages between active debug adapters and Zed
426 ///
427 /// Default: true
428 pub log_dap_communications: Option<bool>,
429 /// Whether to format dap messages in when adding them to debug adapter logger
430 ///
431 /// Default: true
432 pub format_dap_log_messages: Option<bool>,
433 /// The dock position of the debug panel
434 ///
435 /// Default: Bottom
436 pub dock: Option<DockPosition>,
437}
438
439/// The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
440#[derive(
441 PartialEq,
442 Eq,
443 Debug,
444 Hash,
445 Clone,
446 Copy,
447 Deserialize,
448 Serialize,
449 JsonSchema,
450 MergeFrom,
451 strum::VariantArray,
452 strum::VariantNames,
453)]
454#[serde(rename_all = "snake_case")]
455pub enum SteppingGranularity {
456 /// The step should allow the program to run until the current statement has finished executing.
457 /// The meaning of a statement is determined by the adapter and it may be considered equivalent to a line.
458 /// For example 'for(int i = 0; i < 10; i++)' could be considered to have 3 statements 'int i = 0', 'i < 10', and 'i++'.
459 Statement,
460 /// The step should allow the program to run until the current source line has executed.
461 Line,
462 /// The step should allow one instruction to execute (e.g. one x86 instruction).
463 Instruction,
464}
465
466#[derive(
467 Copy,
468 Clone,
469 Debug,
470 Serialize,
471 Deserialize,
472 JsonSchema,
473 MergeFrom,
474 PartialEq,
475 Eq,
476 strum::VariantArray,
477 strum::VariantNames,
478)]
479#[serde(rename_all = "snake_case")]
480pub enum DockPosition {
481 Left,
482 Bottom,
483 Right,
484}
485
486/// Configuration of voice calls in Zed.
487#[with_fallible_options]
488#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
489pub struct CallSettingsContent {
490 /// Whether the microphone should be muted when joining a channel or a call.
491 ///
492 /// Default: false
493 pub mute_on_join: Option<bool>,
494
495 /// Whether your current project should be shared when joining an empty channel.
496 ///
497 /// Default: false
498 pub share_on_join: Option<bool>,
499}
500
501#[with_fallible_options]
502#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
503pub struct GitPanelSettingsContent {
504 /// Whether to show the panel button in the status bar.
505 ///
506 /// Default: true
507 pub button: Option<bool>,
508 /// Where to dock the panel.
509 ///
510 /// Default: left
511 pub dock: Option<DockPosition>,
512 /// Default width of the panel in pixels.
513 ///
514 /// Default: 360
515 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
516 pub default_width: Option<f32>,
517 /// How entry statuses are displayed.
518 ///
519 /// Default: icon
520 pub status_style: Option<StatusStyle>,
521
522 /// Whether to show file icons in the git panel.
523 ///
524 /// Default: false
525 pub file_icons: Option<bool>,
526
527 /// Whether to show folder icons or chevrons for directories in the git panel.
528 ///
529 /// Default: true
530 pub folder_icons: Option<bool>,
531
532 /// How and when the scrollbar should be displayed.
533 ///
534 /// Default: inherits editor scrollbar settings
535 pub scrollbar: Option<ScrollbarSettings>,
536
537 /// What the default branch name should be when
538 /// `init.defaultBranch` is not set in git
539 ///
540 /// Default: main
541 pub fallback_branch_name: Option<String>,
542
543 /// Whether to sort entries in the panel by path
544 /// or by status (the default).
545 ///
546 /// Default: false
547 pub sort_by_path: Option<bool>,
548
549 /// Whether to collapse untracked files in the diff panel.
550 ///
551 /// Default: false
552 pub collapse_untracked_diff: Option<bool>,
553
554 /// Whether to show entries with tree or flat view in the panel
555 ///
556 /// Default: false
557 pub tree_view: Option<bool>,
558
559 /// Whether to show the addition/deletion change count next to each file in the Git panel.
560 ///
561 /// Default: true
562 pub diff_stats: Option<bool>,
563
564 /// Whether to show a badge on the git panel icon with the count of uncommitted changes.
565 ///
566 /// Default: false
567 pub show_count_badge: Option<bool>,
568
569 /// Whether the git panel should open on startup.
570 ///
571 /// Default: false
572 pub starts_open: Option<bool>,
573}
574
575#[derive(
576 Default,
577 Copy,
578 Clone,
579 Debug,
580 Serialize,
581 Deserialize,
582 JsonSchema,
583 MergeFrom,
584 PartialEq,
585 Eq,
586 strum::VariantArray,
587 strum::VariantNames,
588)]
589#[serde(rename_all = "snake_case")]
590pub enum StatusStyle {
591 #[default]
592 Icon,
593 LabelColor,
594}
595
596#[with_fallible_options]
597#[derive(
598 Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
599)]
600pub struct ScrollbarSettings {
601 pub show: Option<ShowScrollbar>,
602}
603
604#[with_fallible_options]
605#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
606pub struct NotificationPanelSettingsContent {
607 /// Whether to show the panel button in the status bar.
608 ///
609 /// Default: true
610 pub button: Option<bool>,
611 /// Where to dock the panel.
612 ///
613 /// Default: right
614 pub dock: Option<DockPosition>,
615 /// Default width of the panel in pixels.
616 ///
617 /// Default: 300
618 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
619 pub default_width: Option<f32>,
620 /// Whether to show a badge on the notification panel icon with the count of unread notifications.
621 ///
622 /// Default: false
623 pub show_count_badge: Option<bool>,
624}
625
626#[with_fallible_options]
627#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
628pub struct PanelSettingsContent {
629 /// Whether to show the panel button in the status bar.
630 ///
631 /// Default: true
632 pub button: Option<bool>,
633 /// Where to dock the panel.
634 ///
635 /// Default: left
636 pub dock: Option<DockPosition>,
637 /// Default width of the panel in pixels.
638 ///
639 /// Default: 240
640 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
641 pub default_width: Option<f32>,
642}
643
644#[with_fallible_options]
645#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
646pub struct MessageEditorSettings {
647 /// Whether to automatically replace emoji shortcodes with emoji characters.
648 /// For example: typing `:wave:` gets replaced with `👋`.
649 ///
650 /// Default: false
651 pub auto_replace_emoji_shortcode: Option<bool>,
652}
653
654#[with_fallible_options]
655#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
656pub struct FileFinderSettingsContent {
657 /// Whether to show file icons in the file finder.
658 ///
659 /// Default: true
660 pub file_icons: Option<bool>,
661 /// Determines how much space the file finder can take up in relation to the available window width.
662 ///
663 /// Default: small
664 pub modal_max_width: Option<FileFinderWidthContent>,
665 /// Determines whether the file finder should skip focus for the active file in search results.
666 ///
667 /// Default: true
668 pub skip_focus_for_active_in_search: Option<bool>,
669 /// Whether to use gitignored files when searching.
670 /// Only the file Zed had indexed will be used, not necessary all the gitignored files.
671 ///
672 /// Default: Smart
673 pub include_ignored: Option<IncludeIgnoredContent>,
674 /// Whether to include text channels in file finder results.
675 ///
676 /// Default: false
677 pub include_channels: Option<bool>,
678}
679
680#[derive(
681 Debug,
682 PartialEq,
683 Eq,
684 Clone,
685 Copy,
686 Default,
687 Serialize,
688 Deserialize,
689 JsonSchema,
690 MergeFrom,
691 strum::VariantArray,
692 strum::VariantNames,
693)]
694#[serde(rename_all = "snake_case")]
695pub enum IncludeIgnoredContent {
696 /// Use all gitignored files
697 All,
698 /// Use only the files Zed had indexed
699 Indexed,
700 /// Be smart and search for ignored when called from a gitignored worktree
701 #[default]
702 Smart,
703}
704
705#[derive(
706 Debug,
707 PartialEq,
708 Eq,
709 Clone,
710 Copy,
711 Default,
712 Serialize,
713 Deserialize,
714 JsonSchema,
715 MergeFrom,
716 strum::VariantArray,
717 strum::VariantNames,
718)]
719#[serde(rename_all = "lowercase")]
720pub enum FileFinderWidthContent {
721 #[default]
722 Small,
723 Medium,
724 Large,
725 XLarge,
726 Full,
727}
728
729#[with_fallible_options]
730#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug, JsonSchema, MergeFrom)]
731pub struct VimSettingsContent {
732 pub default_mode: Option<ModeContent>,
733 pub toggle_relative_line_numbers: Option<bool>,
734 pub use_system_clipboard: Option<UseSystemClipboard>,
735 pub use_smartcase_find: Option<bool>,
736 /// When enabled, the `:substitute` command replaces all matches in a line
737 /// by default. The 'g' flag then toggles this behavior.,
738 pub gdefault: Option<bool>,
739 pub custom_digraphs: Option<HashMap<String, Arc<str>>>,
740 pub highlight_on_yank_duration: Option<u64>,
741 pub cursor_shape: Option<CursorShapeSettings>,
742}
743
744#[derive(
745 Copy,
746 Clone,
747 Default,
748 Serialize,
749 Deserialize,
750 JsonSchema,
751 MergeFrom,
752 PartialEq,
753 Debug,
754 strum::VariantArray,
755 strum::VariantNames,
756)]
757#[serde(rename_all = "snake_case")]
758pub enum ModeContent {
759 #[default]
760 Normal,
761 Insert,
762}
763
764/// Controls when to use system clipboard.
765#[derive(
766 Copy,
767 Clone,
768 Debug,
769 Serialize,
770 Deserialize,
771 PartialEq,
772 Eq,
773 JsonSchema,
774 MergeFrom,
775 strum::VariantArray,
776 strum::VariantNames,
777)]
778#[serde(rename_all = "snake_case")]
779pub enum UseSystemClipboard {
780 /// Don't use system clipboard.
781 Never,
782 /// Use system clipboard.
783 Always,
784 /// Use system clipboard for yank operations.
785 OnYank,
786}
787
788/// Cursor shape configuration for insert mode in Vim.
789#[derive(
790 Copy,
791 Clone,
792 Debug,
793 Serialize,
794 Deserialize,
795 PartialEq,
796 Eq,
797 JsonSchema,
798 MergeFrom,
799 strum::VariantArray,
800 strum::VariantNames,
801)]
802#[serde(rename_all = "snake_case")]
803pub enum VimInsertModeCursorShape {
804 /// Inherit cursor shape from the editor's base cursor_shape setting.
805 Inherit,
806 /// Vertical bar cursor.
807 Bar,
808 /// Block cursor that surrounds the character.
809 Block,
810 /// Underline cursor.
811 Underline,
812 /// Hollow box cursor.
813 Hollow,
814}
815
816/// The settings for cursor shape.
817#[with_fallible_options]
818#[derive(
819 Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom,
820)]
821pub struct CursorShapeSettings {
822 /// Cursor shape for the normal mode.
823 ///
824 /// Default: block
825 pub normal: Option<CursorShape>,
826 /// Cursor shape for the replace mode.
827 ///
828 /// Default: underline
829 pub replace: Option<CursorShape>,
830 /// Cursor shape for the visual mode.
831 ///
832 /// Default: block
833 pub visual: Option<CursorShape>,
834 /// Cursor shape for the insert mode.
835 ///
836 /// The default value follows the primary cursor_shape.
837 pub insert: Option<VimInsertModeCursorShape>,
838}
839
840/// Settings specific to journaling
841#[with_fallible_options]
842#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
843pub struct JournalSettingsContent {
844 /// The path of the directory where journal entries are stored.
845 ///
846 /// Default: `~`
847 pub path: Option<String>,
848 /// What format to display the hours in.
849 ///
850 /// Default: hour12
851 pub hour_format: Option<HourFormat>,
852}
853
854#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
855#[serde(rename_all = "snake_case")]
856pub enum HourFormat {
857 #[default]
858 Hour12,
859 Hour24,
860}
861
862#[with_fallible_options]
863#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
864pub struct OutlinePanelSettingsContent {
865 /// Whether to show the outline panel button in the status bar.
866 ///
867 /// Default: true
868 pub button: Option<bool>,
869 /// Customize default width (in pixels) taken by outline panel
870 ///
871 /// Default: 240
872 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
873 pub default_width: Option<f32>,
874 /// The position of outline panel
875 ///
876 /// Default: left
877 pub dock: Option<DockSide>,
878 /// Whether to show file icons in the outline panel.
879 ///
880 /// Default: true
881 pub file_icons: Option<bool>,
882 /// Whether to show folder icons or chevrons for directories in the outline panel.
883 ///
884 /// Default: true
885 pub folder_icons: Option<bool>,
886 /// Whether to show the git status in the outline panel.
887 ///
888 /// Default: true
889 pub git_status: Option<bool>,
890 /// Amount of indentation (in pixels) for nested items.
891 ///
892 /// Default: 20
893 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
894 pub indent_size: Option<f32>,
895 /// Whether to reveal it in the outline panel automatically,
896 /// when a corresponding project entry becomes active.
897 /// Gitignored entries are never auto revealed.
898 ///
899 /// Default: true
900 pub auto_reveal_entries: Option<bool>,
901 /// Whether to fold directories automatically
902 /// when directory has only one directory inside.
903 ///
904 /// Default: true
905 pub auto_fold_dirs: Option<bool>,
906 /// Settings related to indent guides in the outline panel.
907 pub indent_guides: Option<IndentGuidesSettingsContent>,
908 /// Scrollbar-related settings
909 pub scrollbar: Option<ScrollbarSettingsContent>,
910 /// Default depth to expand outline items in the current file.
911 /// The default depth to which outline entries are expanded on reveal.
912 /// - Set to 0 to collapse all items that have children
913 /// - Set to 1 or higher to collapse items at that depth or deeper
914 ///
915 /// Default: 100
916 pub expand_outlines_with_depth: Option<usize>,
917}
918
919#[derive(
920 Clone,
921 Copy,
922 Debug,
923 PartialEq,
924 Eq,
925 Serialize,
926 Deserialize,
927 JsonSchema,
928 MergeFrom,
929 strum::VariantArray,
930 strum::VariantNames,
931)]
932#[serde(rename_all = "snake_case")]
933pub enum DockSide {
934 Left,
935 Right,
936}
937
938#[derive(
939 Copy,
940 Clone,
941 Debug,
942 PartialEq,
943 Eq,
944 Deserialize,
945 Serialize,
946 JsonSchema,
947 MergeFrom,
948 strum::VariantArray,
949 strum::VariantNames,
950)]
951#[serde(rename_all = "snake_case")]
952pub enum ShowIndentGuides {
953 Always,
954 Never,
955}
956
957#[with_fallible_options]
958#[derive(
959 Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq, Default,
960)]
961pub struct IndentGuidesSettingsContent {
962 /// When to show the scrollbar in the outline panel.
963 pub show: Option<ShowIndentGuides>,
964}
965
966#[derive(Clone, Copy, Default, PartialEq, Debug, JsonSchema, MergeFrom, Deserialize, Serialize)]
967#[serde(rename_all = "snake_case")]
968pub enum LineIndicatorFormat {
969 Short,
970 #[default]
971 Long,
972}
973
974/// The settings for the image viewer.
975#[with_fallible_options]
976#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Default, PartialEq)]
977pub struct ImageViewerSettingsContent {
978 /// The unit to use for displaying image file sizes.
979 ///
980 /// Default: "binary"
981 pub unit: Option<ImageFileSizeUnit>,
982}
983
984#[with_fallible_options]
985#[derive(
986 Clone,
987 Copy,
988 Debug,
989 Serialize,
990 Deserialize,
991 JsonSchema,
992 MergeFrom,
993 Default,
994 PartialEq,
995 strum::VariantArray,
996 strum::VariantNames,
997)]
998#[serde(rename_all = "snake_case")]
999pub enum ImageFileSizeUnit {
1000 /// Displays file size in binary units (e.g., KiB, MiB).
1001 #[default]
1002 Binary,
1003 /// Displays file size in decimal units (e.g., KB, MB).
1004 Decimal,
1005}
1006
1007#[with_fallible_options]
1008#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
1009pub struct RemoteSettingsContent {
1010 pub ssh_connections: Option<Vec<SshConnection>>,
1011 pub wsl_connections: Option<Vec<WslConnection>>,
1012 pub dev_container_connections: Option<Vec<DevContainerConnection>>,
1013 pub read_ssh_config: Option<bool>,
1014 pub use_podman: Option<bool>,
1015}
1016
1017#[with_fallible_options]
1018#[derive(
1019 Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom, Hash,
1020)]
1021pub struct DevContainerConnection {
1022 pub name: String,
1023 pub remote_user: String,
1024 pub container_id: String,
1025 pub use_podman: bool,
1026}
1027
1028#[with_fallible_options]
1029#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
1030pub struct SshConnection {
1031 pub host: String,
1032 pub username: Option<String>,
1033 pub port: Option<u16>,
1034 #[serde(default)]
1035 pub args: Vec<String>,
1036 #[serde(default)]
1037 pub projects: collections::BTreeSet<RemoteProject>,
1038 /// Name to use for this server in UI.
1039 pub nickname: Option<String>,
1040 // By default Zed will download the binary to the host directly.
1041 // If this is set to true, Zed will download the binary to your local machine,
1042 // and then upload it over the SSH connection. Useful if your SSH server has
1043 // limited outbound internet access.
1044 pub upload_binary_over_ssh: Option<bool>,
1045
1046 pub port_forwards: Option<Vec<SshPortForwardOption>>,
1047 /// Timeout in seconds for SSH connection and downloading the remote server binary.
1048 /// Defaults to 10 seconds if not specified.
1049 pub connection_timeout: Option<u16>,
1050}
1051
1052#[derive(Clone, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom, Debug)]
1053pub struct WslConnection {
1054 pub distro_name: String,
1055 pub user: Option<String>,
1056 #[serde(default)]
1057 pub projects: BTreeSet<RemoteProject>,
1058}
1059
1060#[with_fallible_options]
1061#[derive(
1062 Clone, Debug, Default, Serialize, PartialEq, Eq, PartialOrd, Ord, Deserialize, JsonSchema,
1063)]
1064pub struct RemoteProject {
1065 pub paths: Vec<String>,
1066}
1067
1068#[with_fallible_options]
1069#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema, MergeFrom)]
1070pub struct SshPortForwardOption {
1071 pub local_host: Option<String>,
1072 pub local_port: u16,
1073 pub remote_host: Option<String>,
1074 pub remote_port: u16,
1075}
1076
1077/// Settings for configuring REPL display and behavior.
1078#[with_fallible_options]
1079#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
1080pub struct ReplSettingsContent {
1081 /// Maximum number of lines to keep in REPL's scrollback buffer.
1082 /// Clamped with [4, 256] range.
1083 ///
1084 /// Default: 32
1085 pub max_lines: Option<usize>,
1086 /// Maximum number of columns to keep in REPL's scrollback buffer.
1087 /// Clamped with [20, 512] range.
1088 ///
1089 /// Default: 128
1090 pub max_columns: Option<usize>,
1091 /// Whether to show small single-line outputs inline instead of in a block.
1092 ///
1093 /// Default: true
1094 pub inline_output: Option<bool>,
1095 /// Maximum number of characters for an output to be shown inline.
1096 /// Only applies when `inline_output` is true.
1097 ///
1098 /// Default: 50
1099 pub inline_output_max_length: Option<usize>,
1100 /// Maximum number of lines of output to display before scrolling.
1101 /// Set to 0 to disable output height limits.
1102 ///
1103 /// Default: 0
1104 pub output_max_height_lines: Option<usize>,
1105}
1106
1107/// Settings for configuring the which-key popup behaviour.
1108#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
1109pub struct WhichKeySettingsContent {
1110 /// Whether to show the which-key popup when holding down key combinations
1111 ///
1112 /// Default: false
1113 pub enabled: Option<bool>,
1114 /// Delay in milliseconds before showing the which-key popup.
1115 ///
1116 /// Default: 700
1117 pub delay_ms: Option<u64>,
1118}
1119
1120// An ExtendingVec in the settings can only accumulate new values.
1121//
1122// This is useful for things like private files where you only want
1123// to allow new values to be added.
1124//
1125// Consider using a HashMap<String, bool> instead of this type
1126// (like auto_install_extensions) so that user settings files can both add
1127// and remove values from the set.
1128#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1129pub struct ExtendingVec<T>(pub Vec<T>);
1130
1131impl<T> Into<Vec<T>> for ExtendingVec<T> {
1132 fn into(self) -> Vec<T> {
1133 self.0
1134 }
1135}
1136impl<T> From<Vec<T>> for ExtendingVec<T> {
1137 fn from(vec: Vec<T>) -> Self {
1138 ExtendingVec(vec)
1139 }
1140}
1141
1142impl<T: Clone> merge_from::MergeFrom for ExtendingVec<T> {
1143 fn merge_from(&mut self, other: &Self) {
1144 self.0.extend_from_slice(other.0.as_slice());
1145 }
1146}
1147
1148// A SaturatingBool in the settings can only ever be set to true,
1149// later attempts to set it to false will be ignored.
1150//
1151// Used by `disable_ai`.
1152#[derive(Debug, Default, Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1153pub struct SaturatingBool(pub bool);
1154
1155impl From<bool> for SaturatingBool {
1156 fn from(value: bool) -> Self {
1157 SaturatingBool(value)
1158 }
1159}
1160
1161impl From<SaturatingBool> for bool {
1162 fn from(value: SaturatingBool) -> bool {
1163 value.0
1164 }
1165}
1166
1167impl merge_from::MergeFrom for SaturatingBool {
1168 fn merge_from(&mut self, other: &Self) {
1169 self.0 |= other.0
1170 }
1171}
1172
1173#[derive(
1174 Copy,
1175 Clone,
1176 Default,
1177 Debug,
1178 PartialEq,
1179 Eq,
1180 PartialOrd,
1181 Ord,
1182 Serialize,
1183 Deserialize,
1184 MergeFrom,
1185 JsonSchema,
1186 derive_more::FromStr,
1187)]
1188#[serde(transparent)]
1189pub struct DelayMs(pub u64);
1190
1191impl From<u64> for DelayMs {
1192 fn from(n: u64) -> Self {
1193 Self(n)
1194 }
1195}
1196
1197impl std::fmt::Display for DelayMs {
1198 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1199 write!(f, "{}ms", self.0)
1200 }
1201}