1use std::num::NonZeroUsize;
2
3use collections::HashMap;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use settings_macros::{MergeFrom, with_fallible_options};
7
8use crate::{
9 CenteredPaddingSettings, DelayMs, DockPosition, DockSide, InactiveOpacity, ShowIndentGuides,
10 ShowScrollbar, serialize_optional_f32_with_two_decimal_places,
11};
12
13#[with_fallible_options]
14#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
15pub struct WorkspaceSettingsContent {
16 /// Active pane styling settings.
17 pub active_pane_modifiers: Option<ActivePaneModifiers>,
18 /// The text rendering mode to use.
19 ///
20 /// Default: platform_default
21 pub text_rendering_mode: Option<TextRenderingMode>,
22 /// Layout mode for the bottom dock
23 ///
24 /// Default: contained
25 pub bottom_dock_layout: Option<BottomDockLayout>,
26 /// Direction to split horizontally.
27 ///
28 /// Default: "up"
29 pub pane_split_direction_horizontal: Option<PaneSplitDirectionHorizontal>,
30 /// Direction to split vertically.
31 ///
32 /// Default: "left"
33 pub pane_split_direction_vertical: Option<PaneSplitDirectionVertical>,
34 /// Centered layout related settings.
35 pub centered_layout: Option<CenteredLayoutSettings>,
36 /// Whether or not to prompt the user to confirm before closing the application.
37 ///
38 /// Default: false
39 pub confirm_quit: Option<bool>,
40 /// Whether or not to show the call status icon in the status bar.
41 ///
42 /// Default: true
43 pub show_call_status_icon: Option<bool>,
44 /// When to automatically save edited buffers.
45 ///
46 /// Default: off
47 pub autosave: Option<AutosaveSetting>,
48 /// Controls previous session restoration in freshly launched Zed instance.
49 /// Values: empty_tab, last_workspace, last_session, launchpad
50 /// Default: last_session
51 pub restore_on_startup: Option<RestoreOnStartupBehavior>,
52 /// Whether to attempt to restore previous file's state when opening it again.
53 /// The state is stored per pane.
54 /// When disabled, defaults are applied instead of the state restoration.
55 ///
56 /// E.g. for editors, selections, folds and scroll positions are restored, if the same file is closed and, later, opened again in the same pane.
57 /// When disabled, a single selection in the very beginning of the file, zero scroll position and no folds state is used as a default.
58 ///
59 /// Default: true
60 pub restore_on_file_reopen: Option<bool>,
61 /// The size of the workspace split drop targets on the outer edges.
62 /// Given as a fraction that will be multiplied by the smaller dimension of the workspace.
63 ///
64 /// Default: `0.2` (20% of the smaller dimension of the workspace)
65 #[serde(serialize_with = "serialize_optional_f32_with_two_decimal_places")]
66 pub drop_target_size: Option<f32>,
67 /// Whether to close the window when using 'close active item' on a workspace with no tabs
68 ///
69 /// Default: auto ("on" on macOS, "off" otherwise)
70 pub when_closing_with_no_tabs: Option<CloseWindowWhenNoItems>,
71 /// Whether to use the system provided dialogs for Open and Save As.
72 /// When set to false, Zed will use the built-in keyboard-first pickers.
73 ///
74 /// Default: true
75 pub use_system_path_prompts: Option<bool>,
76 /// Whether to use the system provided prompts.
77 /// When set to false, Zed will use the built-in prompts.
78 /// Note that this setting has no effect on Linux, where Zed will always
79 /// use the built-in prompts.
80 ///
81 /// Default: true
82 pub use_system_prompts: Option<bool>,
83 /// Aliases for the command palette. When you type a key in this map,
84 /// it will be assumed to equal the value.
85 ///
86 /// Default: true
87 #[serde(default)]
88 pub command_aliases: HashMap<String, String>,
89 /// Maximum open tabs in a pane. Will not close an unsaved
90 /// tab. Set to `None` for unlimited tabs.
91 ///
92 /// Default: none
93 pub max_tabs: Option<NonZeroUsize>,
94 /// What to do when the last window is closed
95 ///
96 /// Default: auto (nothing on macOS, "app quit" otherwise)
97 pub on_last_window_closed: Option<OnLastWindowClosed>,
98 /// Whether to resize all the panels in a dock when resizing the dock.
99 ///
100 /// Default: ["left"]
101 pub resize_all_panels_in_dock: Option<Vec<DockPosition>>,
102 /// Whether to automatically close files that have been deleted on disk.
103 ///
104 /// Default: false
105 pub close_on_file_delete: Option<bool>,
106 /// Whether to allow windows to tab together based on the user’s tabbing preference (macOS only).
107 ///
108 /// Default: false
109 pub use_system_window_tabs: Option<bool>,
110 /// Whether to show padding for zoomed panels.
111 /// When enabled, zoomed bottom panels will have some top padding,
112 /// while zoomed left/right panels will have padding to the right/left (respectively).
113 ///
114 /// Default: true
115 pub zoomed_padding: Option<bool>,
116 /// Whether toggling a panel (e.g. with its keyboard shortcut) also closes
117 /// the panel when it is already focused, instead of just moving focus back
118 /// to the editor.
119 ///
120 /// Default: false
121 pub close_panel_on_toggle: Option<bool>,
122 /// What draws window decorations/titlebar, the client application (Zed) or display server
123 /// Default: client
124 pub window_decorations: Option<WindowDecorations>,
125}
126
127#[with_fallible_options]
128#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
129pub struct ItemSettingsContent {
130 /// Whether to show the Git file status on a tab item.
131 ///
132 /// Default: false
133 pub git_status: Option<bool>,
134 /// Position of the close button in a tab.
135 ///
136 /// Default: right
137 pub close_position: Option<ClosePosition>,
138 /// Whether to show the file icon for a tab.
139 ///
140 /// Default: false
141 pub file_icons: Option<bool>,
142 /// What to do after closing the current tab.
143 ///
144 /// Default: history
145 pub activate_on_close: Option<ActivateOnClose>,
146 /// Which files containing diagnostic errors/warnings to mark in the tabs.
147 /// This setting can take the following three values:
148 ///
149 /// Default: off
150 pub show_diagnostics: Option<ShowDiagnostics>,
151 /// Whether to always show the close button on tabs.
152 ///
153 /// Default: false
154 pub show_close_button: Option<ShowCloseButton>,
155}
156
157#[with_fallible_options]
158#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
159pub struct PreviewTabsSettingsContent {
160 /// Whether to show opened editors as preview tabs.
161 /// Preview tabs do not stay open, are reused until explicitly set to be kept open opened (via double-click or editing) and show file names in italic.
162 ///
163 /// Default: true
164 pub enabled: Option<bool>,
165 /// Whether to open tabs in preview mode when opened from the project panel with a single click.
166 ///
167 /// Default: true
168 pub enable_preview_from_project_panel: Option<bool>,
169 /// Whether to open tabs in preview mode when selected from the file finder.
170 ///
171 /// Default: false
172 pub enable_preview_from_file_finder: Option<bool>,
173 /// Whether to open tabs in preview mode when opened from a multibuffer.
174 ///
175 /// Default: true
176 pub enable_preview_from_multibuffer: Option<bool>,
177 /// Whether to open tabs in preview mode when code navigation is used to open a multibuffer.
178 ///
179 /// Default: false
180 pub enable_preview_multibuffer_from_code_navigation: Option<bool>,
181 /// Whether to open tabs in preview mode when code navigation is used to open a single file.
182 ///
183 /// Default: true
184 pub enable_preview_file_from_code_navigation: Option<bool>,
185 /// Whether to keep tabs in preview mode when code navigation is used to navigate away from them.
186 /// If `enable_preview_file_from_code_navigation` or `enable_preview_multibuffer_from_code_navigation` is also true, the new tab may replace the existing one.
187 ///
188 /// Default: false
189 pub enable_keep_preview_on_code_navigation: Option<bool>,
190}
191
192#[derive(
193 Copy,
194 Clone,
195 Debug,
196 PartialEq,
197 Default,
198 Serialize,
199 Deserialize,
200 JsonSchema,
201 MergeFrom,
202 strum::VariantArray,
203 strum::VariantNames,
204)]
205#[serde(rename_all = "lowercase")]
206pub enum ClosePosition {
207 Left,
208 #[default]
209 Right,
210}
211
212#[derive(
213 Copy,
214 Clone,
215 Debug,
216 PartialEq,
217 Default,
218 Serialize,
219 Deserialize,
220 JsonSchema,
221 MergeFrom,
222 strum::VariantArray,
223 strum::VariantNames,
224)]
225#[serde(rename_all = "lowercase")]
226pub enum ShowCloseButton {
227 Always,
228 #[default]
229 Hover,
230 Hidden,
231}
232
233#[derive(
234 Copy,
235 Clone,
236 Debug,
237 Default,
238 Serialize,
239 Deserialize,
240 JsonSchema,
241 MergeFrom,
242 PartialEq,
243 Eq,
244 strum::VariantArray,
245 strum::VariantNames,
246)]
247#[serde(rename_all = "snake_case")]
248pub enum ShowDiagnostics {
249 #[default]
250 Off,
251 Errors,
252 All,
253}
254
255#[derive(
256 Copy,
257 Clone,
258 Debug,
259 PartialEq,
260 Default,
261 Serialize,
262 Deserialize,
263 JsonSchema,
264 MergeFrom,
265 strum::VariantArray,
266 strum::VariantNames,
267)]
268#[serde(rename_all = "snake_case")]
269pub enum ActivateOnClose {
270 #[default]
271 History,
272 Neighbour,
273 LeftNeighbour,
274}
275
276#[with_fallible_options]
277#[derive(Copy, Clone, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
278#[serde(rename_all = "snake_case")]
279pub struct ActivePaneModifiers {
280 /// Size of the border surrounding the active pane.
281 /// When set to 0, the active pane doesn't have any border.
282 /// The border is drawn inset.
283 ///
284 /// Default: `0.0`
285 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
286 pub border_size: Option<f32>,
287 /// Opacity of inactive panels.
288 /// When set to 1.0, the inactive panes have the same opacity as the active one.
289 /// If set to 0, the inactive panes content will not be visible at all.
290 /// Values are clamped to the [0.0, 1.0] range.
291 ///
292 /// Default: `1.0`
293 #[schemars(range(min = 0.0, max = 1.0))]
294 pub inactive_opacity: Option<InactiveOpacity>,
295}
296
297#[derive(
298 Copy,
299 Clone,
300 Debug,
301 Default,
302 Serialize,
303 Deserialize,
304 PartialEq,
305 JsonSchema,
306 MergeFrom,
307 strum::VariantArray,
308 strum::VariantNames,
309)]
310#[serde(rename_all = "snake_case")]
311pub enum BottomDockLayout {
312 /// Contained between the left and right docks
313 #[default]
314 Contained,
315 /// Takes up the full width of the window
316 Full,
317 /// Extends under the left dock while snapping to the right dock
318 LeftAligned,
319 /// Extends under the right dock while snapping to the left dock
320 RightAligned,
321}
322
323#[derive(
324 Copy,
325 Clone,
326 Default,
327 Debug,
328 Serialize,
329 Deserialize,
330 PartialEq,
331 JsonSchema,
332 MergeFrom,
333 strum::VariantArray,
334 strum::VariantNames,
335)]
336#[serde(rename_all = "snake_case")]
337pub enum WindowDecorations {
338 /// Zed draws its own window decorations/titlebar (client-side decoration)
339 #[default]
340 Client,
341 /// Show system's window titlebar (server-side decoration; not supported by GNOME Wayland)
342 Server,
343}
344
345#[derive(
346 Copy,
347 Clone,
348 PartialEq,
349 Default,
350 Serialize,
351 Deserialize,
352 JsonSchema,
353 MergeFrom,
354 Debug,
355 strum::VariantArray,
356 strum::VariantNames,
357)]
358#[serde(rename_all = "snake_case")]
359pub enum CloseWindowWhenNoItems {
360 /// Match platform conventions by default, so "on" on macOS and "off" everywhere else
361 #[default]
362 PlatformDefault,
363 /// Close the window when there are no tabs
364 CloseWindow,
365 /// Leave the window open when there are no tabs
366 KeepWindowOpen,
367}
368
369impl CloseWindowWhenNoItems {
370 pub fn should_close(&self) -> bool {
371 match self {
372 CloseWindowWhenNoItems::PlatformDefault => cfg!(target_os = "macos"),
373 CloseWindowWhenNoItems::CloseWindow => true,
374 CloseWindowWhenNoItems::KeepWindowOpen => false,
375 }
376 }
377}
378
379#[derive(
380 Copy,
381 Clone,
382 PartialEq,
383 Eq,
384 Default,
385 Serialize,
386 Deserialize,
387 JsonSchema,
388 MergeFrom,
389 Debug,
390 strum::VariantArray,
391 strum::VariantNames,
392)]
393#[serde(rename_all = "snake_case")]
394pub enum RestoreOnStartupBehavior {
395 /// Always start with an empty editor tab
396 #[serde(alias = "none")]
397 EmptyTab,
398 /// Restore the workspace that was closed last.
399 LastWorkspace,
400 /// Restore all workspaces that were open when quitting Zed.
401 #[default]
402 LastSession,
403 /// Show the launchpad with recent projects (no tabs).
404 Launchpad,
405}
406
407#[with_fallible_options]
408#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
409pub struct TabBarSettingsContent {
410 /// Whether or not to show the tab bar in the editor.
411 ///
412 /// Default: true
413 pub show: Option<bool>,
414 /// Whether or not to show the navigation history buttons in the tab bar.
415 ///
416 /// Default: true
417 pub show_nav_history_buttons: Option<bool>,
418 /// Whether or not to show the tab bar buttons.
419 ///
420 /// Default: true
421 pub show_tab_bar_buttons: Option<bool>,
422 /// Whether or not to show pinned tabs in a separate row.
423 /// When enabled, pinned tabs appear in a top row and unpinned tabs in a bottom row.
424 ///
425 /// Default: false
426 pub show_pinned_tabs_in_separate_row: Option<bool>,
427}
428
429#[with_fallible_options]
430#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq, Eq)]
431pub struct StatusBarSettingsContent {
432 /// Whether to show the status bar.
433 ///
434 /// Default: true
435 #[serde(rename = "experimental.show")]
436 pub show: Option<bool>,
437 /// Whether to show the name of the active file in the status bar.
438 ///
439 /// Default: false
440 pub show_active_file: Option<bool>,
441 /// Whether to display the active language button in the status bar.
442 ///
443 /// Default: true
444 pub active_language_button: Option<bool>,
445 /// Whether to show the cursor position button in the status bar.
446 ///
447 /// Default: true
448 pub cursor_position_button: Option<bool>,
449 /// Whether to show active line endings button in the status bar.
450 ///
451 /// Default: false
452 pub line_endings_button: Option<bool>,
453 /// Whether to show the active encoding button in the status bar.
454 ///
455 /// Default: non_utf8
456 pub active_encoding_button: Option<EncodingDisplayOptions>,
457}
458
459#[derive(
460 Copy,
461 Clone,
462 Debug,
463 Eq,
464 PartialEq,
465 Default,
466 Serialize,
467 Deserialize,
468 JsonSchema,
469 MergeFrom,
470 strum::VariantNames,
471 strum::VariantArray,
472)]
473#[serde(rename_all = "snake_case")]
474pub enum EncodingDisplayOptions {
475 Enabled,
476 Disabled,
477 #[default]
478 NonUtf8,
479}
480impl EncodingDisplayOptions {
481 pub fn should_show(&self, is_utf8: bool, has_bom: bool) -> bool {
482 match self {
483 Self::Disabled => false,
484 Self::Enabled => true,
485 Self::NonUtf8 => {
486 let is_standard_utf8 = is_utf8 && !has_bom;
487 !is_standard_utf8
488 }
489 }
490 }
491}
492
493#[derive(
494 Copy,
495 Clone,
496 Debug,
497 Serialize,
498 Deserialize,
499 PartialEq,
500 Eq,
501 JsonSchema,
502 MergeFrom,
503 strum::EnumDiscriminants,
504)]
505#[strum_discriminants(derive(strum::VariantArray, strum::VariantNames, strum::FromRepr))]
506#[serde(rename_all = "snake_case")]
507pub enum AutosaveSetting {
508 /// Disable autosave.
509 Off,
510 /// Save after inactivity period of `milliseconds`.
511 AfterDelay { milliseconds: DelayMs },
512 /// Autosave when focus changes.
513 OnFocusChange,
514 /// Autosave when the active window changes.
515 OnWindowChange,
516}
517
518impl AutosaveSetting {
519 pub fn should_save_on_close(&self) -> bool {
520 matches!(
521 &self,
522 AutosaveSetting::OnFocusChange
523 | AutosaveSetting::OnWindowChange
524 | AutosaveSetting::AfterDelay { .. }
525 )
526 }
527}
528
529#[derive(
530 Copy,
531 Clone,
532 Debug,
533 Serialize,
534 Deserialize,
535 PartialEq,
536 Eq,
537 JsonSchema,
538 MergeFrom,
539 strum::VariantArray,
540 strum::VariantNames,
541)]
542#[serde(rename_all = "snake_case")]
543pub enum PaneSplitDirectionHorizontal {
544 Up,
545 Down,
546}
547
548#[derive(
549 Copy,
550 Clone,
551 Debug,
552 Serialize,
553 Deserialize,
554 PartialEq,
555 Eq,
556 JsonSchema,
557 MergeFrom,
558 strum::VariantArray,
559 strum::VariantNames,
560)]
561#[serde(rename_all = "snake_case")]
562pub enum PaneSplitDirectionVertical {
563 Left,
564 Right,
565}
566
567#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
568#[serde(rename_all = "snake_case")]
569#[with_fallible_options]
570pub struct CenteredLayoutSettings {
571 /// The relative width of the left padding of the central pane from the
572 /// workspace when the centered layout is used.
573 ///
574 /// Default: 0.2
575 pub left_padding: Option<CenteredPaddingSettings>,
576 // The relative width of the right padding of the central pane from the
577 // workspace when the centered layout is used.
578 ///
579 /// Default: 0.2
580 pub right_padding: Option<CenteredPaddingSettings>,
581}
582
583#[derive(
584 Copy,
585 Clone,
586 Default,
587 Serialize,
588 Deserialize,
589 JsonSchema,
590 MergeFrom,
591 PartialEq,
592 Debug,
593 strum::VariantArray,
594 strum::VariantNames,
595)]
596#[serde(rename_all = "snake_case")]
597pub enum OnLastWindowClosed {
598 /// Match platform conventions by default, so don't quit on macOS, and quit on other platforms
599 #[default]
600 PlatformDefault,
601 /// Quit the application the last window is closed
602 QuitApp,
603}
604
605#[derive(
606 Copy,
607 Clone,
608 Default,
609 Serialize,
610 Deserialize,
611 JsonSchema,
612 MergeFrom,
613 PartialEq,
614 Eq,
615 Debug,
616 strum::VariantArray,
617 strum::VariantNames,
618)]
619#[serde(rename_all = "snake_case")]
620pub enum TextRenderingMode {
621 /// Use platform default behavior.
622 #[default]
623 PlatformDefault,
624 /// Use subpixel (ClearType-style) text rendering.
625 Subpixel,
626 /// Use grayscale text rendering.
627 Grayscale,
628}
629
630impl OnLastWindowClosed {
631 pub fn is_quit_app(&self) -> bool {
632 match self {
633 OnLastWindowClosed::PlatformDefault => false,
634 OnLastWindowClosed::QuitApp => true,
635 }
636 }
637}
638
639#[with_fallible_options]
640#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
641pub struct ProjectPanelAutoOpenSettings {
642 /// Whether to automatically open newly created files in the editor.
643 ///
644 /// Default: true
645 pub on_create: Option<bool>,
646 /// Whether to automatically open files after pasting or duplicating them.
647 ///
648 /// Default: true
649 pub on_paste: Option<bool>,
650 /// Whether to automatically open files dropped from external sources.
651 ///
652 /// Default: true
653 pub on_drop: Option<bool>,
654}
655
656#[with_fallible_options]
657#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
658pub struct ProjectPanelSettingsContent {
659 /// Whether to show the project panel button in the status bar.
660 ///
661 /// Default: true
662 pub button: Option<bool>,
663 /// Whether to hide gitignore files in the project panel.
664 ///
665 /// Default: false
666 pub hide_gitignore: Option<bool>,
667 /// Customize default width (in pixels) taken by project panel
668 ///
669 /// Default: 240
670 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
671 pub default_width: Option<f32>,
672 /// The position of project panel
673 ///
674 /// Default: left
675 pub dock: Option<DockSide>,
676 /// Spacing between worktree entries in the project panel.
677 ///
678 /// Default: comfortable
679 pub entry_spacing: Option<ProjectPanelEntrySpacing>,
680 /// Whether to show file icons in the project panel.
681 ///
682 /// Default: true
683 pub file_icons: Option<bool>,
684 /// Whether to show folder icons or chevrons for directories in the project panel.
685 ///
686 /// Default: true
687 pub folder_icons: Option<bool>,
688 /// Whether to show the git status in the project panel.
689 ///
690 /// Default: true
691 pub git_status: Option<bool>,
692 /// Amount of indentation (in pixels) for nested items.
693 ///
694 /// Default: 20
695 #[serde(serialize_with = "serialize_optional_f32_with_two_decimal_places")]
696 pub indent_size: Option<f32>,
697 /// Whether to reveal it in the project panel automatically,
698 /// when a corresponding project entry becomes active.
699 /// Gitignored entries are never auto revealed.
700 ///
701 /// Default: true
702 pub auto_reveal_entries: Option<bool>,
703 /// Whether to fold directories automatically
704 /// when directory has only one directory inside.
705 ///
706 /// Default: true
707 pub auto_fold_dirs: Option<bool>,
708 /// Whether to show folder names with bold text in the project panel.
709 ///
710 /// Default: false
711 pub bold_folder_labels: Option<bool>,
712 /// Whether the project panel should open on startup.
713 ///
714 /// Default: true
715 pub starts_open: Option<bool>,
716 /// Scrollbar-related settings
717 pub scrollbar: Option<ProjectPanelScrollbarSettingsContent>,
718 /// Which files containing diagnostic errors/warnings to mark in the project panel.
719 ///
720 /// Default: all
721 pub show_diagnostics: Option<ShowDiagnostics>,
722 /// Settings related to indent guides in the project panel.
723 pub indent_guides: Option<ProjectPanelIndentGuidesSettings>,
724 /// Whether to hide the root entry when only one folder is open in the window.
725 ///
726 /// Default: false
727 pub hide_root: Option<bool>,
728 /// Whether to hide the hidden entries in the project panel.
729 ///
730 /// Default: false
731 pub hide_hidden: Option<bool>,
732 /// Whether to stick parent directories at top of the project panel.
733 ///
734 /// Default: true
735 pub sticky_scroll: Option<bool>,
736 /// Whether to enable drag-and-drop operations in the project panel.
737 ///
738 /// Default: true
739 pub drag_and_drop: Option<bool>,
740 /// Settings for automatically opening files.
741 pub auto_open: Option<ProjectPanelAutoOpenSettings>,
742 /// How to order sibling entries in the project panel.
743 ///
744 /// Default: directories_first
745 pub sort_mode: Option<ProjectPanelSortMode>,
746 /// Whether to show error and warning count badges next to file names in the project panel.
747 ///
748 /// Default: false
749 pub diagnostic_badges: Option<bool>,
750 /// Whether to show a git status indicator next to file names in the project panel.
751 ///
752 /// Default: false
753 pub git_status_indicator: Option<bool>,
754}
755
756#[derive(
757 Copy,
758 Clone,
759 Debug,
760 Default,
761 Serialize,
762 Deserialize,
763 JsonSchema,
764 MergeFrom,
765 PartialEq,
766 Eq,
767 strum::VariantArray,
768 strum::VariantNames,
769)]
770#[serde(rename_all = "snake_case")]
771pub enum ProjectPanelEntrySpacing {
772 /// Comfortable spacing of entries.
773 #[default]
774 Comfortable,
775 /// The standard spacing of entries.
776 Standard,
777}
778
779#[derive(
780 Copy,
781 Clone,
782 Debug,
783 Default,
784 Serialize,
785 Deserialize,
786 JsonSchema,
787 MergeFrom,
788 PartialEq,
789 Eq,
790 strum::VariantArray,
791 strum::VariantNames,
792)]
793#[serde(rename_all = "snake_case")]
794pub enum ProjectPanelSortMode {
795 /// Show directories first, then files
796 #[default]
797 DirectoriesFirst,
798 /// Mix directories and files together
799 Mixed,
800 /// Show files first, then directories
801 FilesFirst,
802}
803
804#[with_fallible_options]
805#[derive(
806 Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq, Default,
807)]
808pub struct ProjectPanelScrollbarSettingsContent {
809 /// When to show the scrollbar in the project panel.
810 ///
811 /// Default: inherits editor scrollbar settings
812 pub show: Option<ShowScrollbar>,
813 /// Whether to allow horizontal scrolling in the project panel.
814 /// When false, the view is locked to the leftmost position and
815 /// long file names are clipped.
816 ///
817 /// Default: true
818 pub horizontal_scroll: Option<bool>,
819}
820
821#[with_fallible_options]
822#[derive(
823 Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq, Default,
824)]
825pub struct ProjectPanelIndentGuidesSettings {
826 pub show: Option<ShowIndentGuides>,
827}
828
829/// Controls how semantic tokens from language servers are used for syntax highlighting.
830#[derive(
831 Debug,
832 PartialEq,
833 Eq,
834 Clone,
835 Copy,
836 Default,
837 Serialize,
838 Deserialize,
839 JsonSchema,
840 MergeFrom,
841 strum::VariantArray,
842 strum::VariantNames,
843 strum::EnumMessage,
844)]
845#[serde(rename_all = "snake_case")]
846pub enum SemanticTokens {
847 /// Do not request semantic tokens from language servers.
848 #[default]
849 Off,
850 /// Use LSP semantic tokens together with tree-sitter highlighting.
851 Combined,
852 /// Use LSP semantic tokens exclusively, replacing tree-sitter highlighting.
853 Full,
854}
855
856impl SemanticTokens {
857 /// Returns true if semantic tokens should be requested from language servers.
858 pub fn enabled(&self) -> bool {
859 self != &Self::Off
860 }
861
862 /// Returns true if tree-sitter syntax highlighting should be used.
863 /// In `full` mode, tree-sitter is disabled in favor of LSP semantic tokens.
864 pub fn use_tree_sitter(&self) -> bool {
865 self != &Self::Full
866 }
867}
868
869#[derive(
870 Debug,
871 PartialEq,
872 Eq,
873 Clone,
874 Copy,
875 Default,
876 Serialize,
877 Deserialize,
878 JsonSchema,
879 MergeFrom,
880 strum::VariantArray,
881 strum::VariantNames,
882)]
883#[serde(rename_all = "snake_case")]
884pub enum DocumentFoldingRanges {
885 /// Do not request folding ranges from language servers; use tree-sitter and indent-based folding.
886 #[default]
887 Off,
888 /// Use LSP folding wherever possible, falling back to tree-sitter and indent-based folding when no results were returned by the server.
889 On,
890}
891
892impl DocumentFoldingRanges {
893 /// Returns true if LSP folding ranges should be requested from language servers.
894 pub fn enabled(&self) -> bool {
895 self != &Self::Off
896 }
897}
898
899#[derive(
900 Debug,
901 PartialEq,
902 Eq,
903 Clone,
904 Copy,
905 Default,
906 Serialize,
907 Deserialize,
908 JsonSchema,
909 MergeFrom,
910 strum::VariantArray,
911 strum::VariantNames,
912)]
913#[serde(rename_all = "snake_case")]
914pub enum DocumentSymbols {
915 /// Use tree-sitter queries to compute document symbols for outlines and breadcrumbs (default).
916 #[default]
917 #[serde(alias = "tree_sitter")]
918 Off,
919 /// Use the language server's `textDocument/documentSymbol` LSP response for outlines and
920 /// breadcrumbs. When enabled, tree-sitter is not used for document symbols.
921 #[serde(alias = "language_server")]
922 On,
923}
924
925impl DocumentSymbols {
926 /// Returns true if LSP document symbols should be used instead of tree-sitter.
927 pub fn lsp_enabled(&self) -> bool {
928 self == &Self::On
929 }
930}