workspace.rs

  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,
 10    ScrollbarSettingsContent, ShowIndentGuides, 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 display the active language button in the status bar.
438    ///
439    /// Default: true
440    pub active_language_button: Option<bool>,
441    /// Whether to show the cursor position button in the status bar.
442    ///
443    /// Default: true
444    pub cursor_position_button: Option<bool>,
445    /// Whether to show active line endings button in the status bar.
446    ///
447    /// Default: false
448    pub line_endings_button: Option<bool>,
449    /// Whether to show the active encoding button in the status bar.
450    ///
451    /// Default: non_utf8
452    pub active_encoding_button: Option<EncodingDisplayOptions>,
453}
454
455#[derive(
456    Copy,
457    Clone,
458    Debug,
459    Eq,
460    PartialEq,
461    Default,
462    Serialize,
463    Deserialize,
464    JsonSchema,
465    MergeFrom,
466    strum::VariantNames,
467    strum::VariantArray,
468)]
469#[serde(rename_all = "snake_case")]
470pub enum EncodingDisplayOptions {
471    Enabled,
472    Disabled,
473    #[default]
474    NonUtf8,
475}
476impl EncodingDisplayOptions {
477    pub fn should_show(&self, is_utf8: bool, has_bom: bool) -> bool {
478        match self {
479            Self::Disabled => false,
480            Self::Enabled => true,
481            Self::NonUtf8 => {
482                let is_standard_utf8 = is_utf8 && !has_bom;
483                !is_standard_utf8
484            }
485        }
486    }
487}
488
489#[derive(
490    Copy,
491    Clone,
492    Debug,
493    Serialize,
494    Deserialize,
495    PartialEq,
496    Eq,
497    JsonSchema,
498    MergeFrom,
499    strum::EnumDiscriminants,
500)]
501#[strum_discriminants(derive(strum::VariantArray, strum::VariantNames, strum::FromRepr))]
502#[serde(rename_all = "snake_case")]
503pub enum AutosaveSetting {
504    /// Disable autosave.
505    Off,
506    /// Save after inactivity period of `milliseconds`.
507    AfterDelay { milliseconds: DelayMs },
508    /// Autosave when focus changes.
509    OnFocusChange,
510    /// Autosave when the active window changes.
511    OnWindowChange,
512}
513
514impl AutosaveSetting {
515    pub fn should_save_on_close(&self) -> bool {
516        matches!(
517            &self,
518            AutosaveSetting::OnFocusChange
519                | AutosaveSetting::OnWindowChange
520                | AutosaveSetting::AfterDelay { .. }
521        )
522    }
523}
524
525#[derive(
526    Copy,
527    Clone,
528    Debug,
529    Serialize,
530    Deserialize,
531    PartialEq,
532    Eq,
533    JsonSchema,
534    MergeFrom,
535    strum::VariantArray,
536    strum::VariantNames,
537)]
538#[serde(rename_all = "snake_case")]
539pub enum PaneSplitDirectionHorizontal {
540    Up,
541    Down,
542}
543
544#[derive(
545    Copy,
546    Clone,
547    Debug,
548    Serialize,
549    Deserialize,
550    PartialEq,
551    Eq,
552    JsonSchema,
553    MergeFrom,
554    strum::VariantArray,
555    strum::VariantNames,
556)]
557#[serde(rename_all = "snake_case")]
558pub enum PaneSplitDirectionVertical {
559    Left,
560    Right,
561}
562
563#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
564#[serde(rename_all = "snake_case")]
565#[with_fallible_options]
566pub struct CenteredLayoutSettings {
567    /// The relative width of the left padding of the central pane from the
568    /// workspace when the centered layout is used.
569    ///
570    /// Default: 0.2
571    pub left_padding: Option<CenteredPaddingSettings>,
572    // The relative width of the right padding of the central pane from the
573    // workspace when the centered layout is used.
574    ///
575    /// Default: 0.2
576    pub right_padding: Option<CenteredPaddingSettings>,
577}
578
579#[derive(
580    Copy,
581    Clone,
582    Default,
583    Serialize,
584    Deserialize,
585    JsonSchema,
586    MergeFrom,
587    PartialEq,
588    Debug,
589    strum::VariantArray,
590    strum::VariantNames,
591)]
592#[serde(rename_all = "snake_case")]
593pub enum OnLastWindowClosed {
594    /// Match platform conventions by default, so don't quit on macOS, and quit on other platforms
595    #[default]
596    PlatformDefault,
597    /// Quit the application the last window is closed
598    QuitApp,
599}
600
601#[derive(
602    Copy,
603    Clone,
604    Default,
605    Serialize,
606    Deserialize,
607    JsonSchema,
608    MergeFrom,
609    PartialEq,
610    Eq,
611    Debug,
612    strum::VariantArray,
613    strum::VariantNames,
614)]
615#[serde(rename_all = "snake_case")]
616pub enum TextRenderingMode {
617    /// Use platform default behavior.
618    #[default]
619    PlatformDefault,
620    /// Use subpixel (ClearType-style) text rendering.
621    Subpixel,
622    /// Use grayscale text rendering.
623    Grayscale,
624}
625
626impl OnLastWindowClosed {
627    pub fn is_quit_app(&self) -> bool {
628        match self {
629            OnLastWindowClosed::PlatformDefault => false,
630            OnLastWindowClosed::QuitApp => true,
631        }
632    }
633}
634
635#[with_fallible_options]
636#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
637pub struct ProjectPanelAutoOpenSettings {
638    /// Whether to automatically open newly created files in the editor.
639    ///
640    /// Default: true
641    pub on_create: Option<bool>,
642    /// Whether to automatically open files after pasting or duplicating them.
643    ///
644    /// Default: true
645    pub on_paste: Option<bool>,
646    /// Whether to automatically open files dropped from external sources.
647    ///
648    /// Default: true
649    pub on_drop: Option<bool>,
650}
651
652#[with_fallible_options]
653#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
654pub struct ProjectPanelSettingsContent {
655    /// Whether to show the project panel button in the status bar.
656    ///
657    /// Default: true
658    pub button: Option<bool>,
659    /// Whether to hide gitignore files in the project panel.
660    ///
661    /// Default: false
662    pub hide_gitignore: Option<bool>,
663    /// Customize default width (in pixels) taken by project panel
664    ///
665    /// Default: 240
666    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
667    pub default_width: Option<f32>,
668    /// The position of project panel
669    ///
670    /// Default: left
671    pub dock: Option<DockSide>,
672    /// Spacing between worktree entries in the project panel.
673    ///
674    /// Default: comfortable
675    pub entry_spacing: Option<ProjectPanelEntrySpacing>,
676    /// Whether to show file icons in the project panel.
677    ///
678    /// Default: true
679    pub file_icons: Option<bool>,
680    /// Whether to show folder icons or chevrons for directories in the project panel.
681    ///
682    /// Default: true
683    pub folder_icons: Option<bool>,
684    /// Whether to show the git status in the project panel.
685    ///
686    /// Default: true
687    pub git_status: Option<bool>,
688    /// Amount of indentation (in pixels) for nested items.
689    ///
690    /// Default: 20
691    #[serde(serialize_with = "serialize_optional_f32_with_two_decimal_places")]
692    pub indent_size: Option<f32>,
693    /// Whether to reveal it in the project panel automatically,
694    /// when a corresponding project entry becomes active.
695    /// Gitignored entries are never auto revealed.
696    ///
697    /// Default: true
698    pub auto_reveal_entries: Option<bool>,
699    /// Whether to fold directories automatically
700    /// when directory has only one directory inside.
701    ///
702    /// Default: true
703    pub auto_fold_dirs: Option<bool>,
704    /// Whether to show folder names with bold text in the project panel.
705    ///
706    /// Default: false
707    pub bold_folder_labels: Option<bool>,
708    /// Whether the project panel should open on startup.
709    ///
710    /// Default: true
711    pub starts_open: Option<bool>,
712    /// Scrollbar-related settings
713    pub scrollbar: Option<ScrollbarSettingsContent>,
714    /// Which files containing diagnostic errors/warnings to mark in the project panel.
715    ///
716    /// Default: all
717    pub show_diagnostics: Option<ShowDiagnostics>,
718    /// Settings related to indent guides in the project panel.
719    pub indent_guides: Option<ProjectPanelIndentGuidesSettings>,
720    /// Whether to hide the root entry when only one folder is open in the window.
721    ///
722    /// Default: false
723    pub hide_root: Option<bool>,
724    /// Whether to hide the hidden entries in the project panel.
725    ///
726    /// Default: false
727    pub hide_hidden: Option<bool>,
728    /// Whether to stick parent directories at top of the project panel.
729    ///
730    /// Default: true
731    pub sticky_scroll: Option<bool>,
732    /// Whether to enable drag-and-drop operations in the project panel.
733    ///
734    /// Default: true
735    pub drag_and_drop: Option<bool>,
736    /// Settings for automatically opening files.
737    pub auto_open: Option<ProjectPanelAutoOpenSettings>,
738    /// How to order sibling entries in the project panel.
739    ///
740    /// Default: directories_first
741    pub sort_mode: Option<ProjectPanelSortMode>,
742    /// Whether to show error and warning count badges next to file names in the project panel.
743    ///
744    /// Default: true
745    pub diagnostic_badges: Option<bool>,
746}
747
748#[derive(
749    Copy,
750    Clone,
751    Debug,
752    Default,
753    Serialize,
754    Deserialize,
755    JsonSchema,
756    MergeFrom,
757    PartialEq,
758    Eq,
759    strum::VariantArray,
760    strum::VariantNames,
761)]
762#[serde(rename_all = "snake_case")]
763pub enum ProjectPanelEntrySpacing {
764    /// Comfortable spacing of entries.
765    #[default]
766    Comfortable,
767    /// The standard spacing of entries.
768    Standard,
769}
770
771#[derive(
772    Copy,
773    Clone,
774    Debug,
775    Default,
776    Serialize,
777    Deserialize,
778    JsonSchema,
779    MergeFrom,
780    PartialEq,
781    Eq,
782    strum::VariantArray,
783    strum::VariantNames,
784)]
785#[serde(rename_all = "snake_case")]
786pub enum ProjectPanelSortMode {
787    /// Show directories first, then files
788    #[default]
789    DirectoriesFirst,
790    /// Mix directories and files together
791    Mixed,
792    /// Show files first, then directories
793    FilesFirst,
794}
795
796#[with_fallible_options]
797#[derive(
798    Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq, Default,
799)]
800pub struct ProjectPanelIndentGuidesSettings {
801    pub show: Option<ShowIndentGuides>,
802}
803
804/// Controls how semantic tokens from language servers are used for syntax highlighting.
805#[derive(
806    Debug,
807    PartialEq,
808    Eq,
809    Clone,
810    Copy,
811    Default,
812    Serialize,
813    Deserialize,
814    JsonSchema,
815    MergeFrom,
816    strum::VariantArray,
817    strum::VariantNames,
818    strum::EnumMessage,
819)]
820#[serde(rename_all = "snake_case")]
821pub enum SemanticTokens {
822    /// Do not request semantic tokens from language servers.
823    #[default]
824    Off,
825    /// Use LSP semantic tokens together with tree-sitter highlighting.
826    Combined,
827    /// Use LSP semantic tokens exclusively, replacing tree-sitter highlighting.
828    Full,
829}
830
831impl SemanticTokens {
832    /// Returns true if semantic tokens should be requested from language servers.
833    pub fn enabled(&self) -> bool {
834        self != &Self::Off
835    }
836
837    /// Returns true if tree-sitter syntax highlighting should be used.
838    /// In `full` mode, tree-sitter is disabled in favor of LSP semantic tokens.
839    pub fn use_tree_sitter(&self) -> bool {
840        self != &Self::Full
841    }
842}
843
844#[derive(
845    Debug,
846    PartialEq,
847    Eq,
848    Clone,
849    Copy,
850    Default,
851    Serialize,
852    Deserialize,
853    JsonSchema,
854    MergeFrom,
855    strum::VariantArray,
856    strum::VariantNames,
857)]
858#[serde(rename_all = "snake_case")]
859pub enum DocumentFoldingRanges {
860    /// Do not request folding ranges from language servers; use tree-sitter and indent-based folding.
861    #[default]
862    Off,
863    /// Use LSP folding wherever possible, falling back to tree-sitter and indent-based folding when no results were returned by the server.
864    On,
865}
866
867impl DocumentFoldingRanges {
868    /// Returns true if LSP folding ranges should be requested from language servers.
869    pub fn enabled(&self) -> bool {
870        self != &Self::Off
871    }
872}
873
874#[derive(
875    Debug,
876    PartialEq,
877    Eq,
878    Clone,
879    Copy,
880    Default,
881    Serialize,
882    Deserialize,
883    JsonSchema,
884    MergeFrom,
885    strum::VariantArray,
886    strum::VariantNames,
887)]
888#[serde(rename_all = "snake_case")]
889pub enum DocumentSymbols {
890    /// Use tree-sitter queries to compute document symbols for outlines and breadcrumbs (default).
891    #[default]
892    #[serde(alias = "tree_sitter")]
893    Off,
894    /// Use the language server's `textDocument/documentSymbol` LSP response for outlines and
895    /// breadcrumbs. When enabled, tree-sitter is not used for document symbols.
896    #[serde(alias = "language_server")]
897    On,
898}
899
900impl DocumentSymbols {
901    /// Returns true if LSP document symbols should be used instead of tree-sitter.
902    pub fn lsp_enabled(&self) -> bool {
903        self == &Self::On
904    }
905}