1use std::fmt::Display;
2use std::num;
3
4use collections::HashMap;
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7use settings_macros::{MergeFrom, with_fallible_options};
8
9use crate::{
10 DelayMs, DiagnosticSeverityContent, ShowScrollbar, serialize_f32_with_two_decimal_places,
11};
12
13#[with_fallible_options]
14#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
15pub struct EditorSettingsContent {
16 /// Whether the cursor blinks in the editor.
17 ///
18 /// Default: true
19 pub cursor_blink: Option<bool>,
20 /// Cursor shape for the default editor.
21 /// Can be "bar", "block", "underline", or "hollow".
22 ///
23 /// Default: bar
24 pub cursor_shape: Option<CursorShape>,
25 /// Determines when the mouse cursor should be hidden in an editor or input box.
26 ///
27 /// Default: on_typing_and_movement
28 pub hide_mouse: Option<HideMouseMode>,
29 /// Determines how snippets are sorted relative to other completion items.
30 ///
31 /// Default: inline
32 pub snippet_sort_order: Option<SnippetSortOrder>,
33 /// How to highlight the current line in the editor.
34 ///
35 /// Default: all
36 pub current_line_highlight: Option<CurrentLineHighlight>,
37 /// Whether to highlight all occurrences of the selected text in an editor.
38 ///
39 /// Default: true
40 pub selection_highlight: Option<bool>,
41 /// Whether the text selection should have rounded corners.
42 ///
43 /// Default: true
44 pub rounded_selection: Option<bool>,
45 /// The debounce delay before querying highlights from the language
46 /// server based on the current cursor location.
47 ///
48 /// Default: 75
49 pub lsp_highlight_debounce: Option<DelayMs>,
50 /// Whether to show the informational hover box when moving the mouse
51 /// over symbols in the editor.
52 ///
53 /// Default: true
54 pub hover_popover_enabled: Option<bool>,
55 /// Time to wait in milliseconds before showing the informational hover box.
56 /// This delay also applies to auto signature help when `auto_signature_help` is enabled.
57 ///
58 /// Default: 300
59 pub hover_popover_delay: Option<DelayMs>,
60 /// Whether the hover popover sticks when the mouse moves toward it,
61 /// allowing interaction with its contents before it disappears.
62 ///
63 /// Default: true
64 pub hover_popover_sticky: Option<bool>,
65 /// Time to wait in milliseconds before hiding the hover popover
66 /// after the mouse moves away from the hover target.
67 /// Only applies when `hover_popover_sticky` is enabled.
68 ///
69 /// Default: 300
70 pub hover_popover_hiding_delay: Option<DelayMs>,
71 /// Toolbar related settings
72 pub toolbar: Option<ToolbarContent>,
73 /// Scrollbar related settings
74 pub scrollbar: Option<ScrollbarContent>,
75 /// Minimap related settings
76 pub minimap: Option<MinimapContent>,
77 /// Gutter related settings
78 pub gutter: Option<GutterContent>,
79 /// Whether the editor will scroll beyond the last line.
80 ///
81 /// Default: one_page
82 pub scroll_beyond_last_line: Option<ScrollBeyondLastLine>,
83 /// The number of lines to keep above/below the cursor when auto-scrolling.
84 ///
85 /// Default: 3.
86 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
87 pub vertical_scroll_margin: Option<f32>,
88 /// Whether to scroll when clicking near the edge of the visible text area.
89 ///
90 /// Default: false
91 pub autoscroll_on_clicks: Option<bool>,
92 /// The number of characters to keep on either side when scrolling with the mouse.
93 ///
94 /// Default: 5.
95 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
96 pub horizontal_scroll_margin: Option<f32>,
97 /// Scroll sensitivity multiplier. This multiplier is applied
98 /// to both the horizontal and vertical delta values while scrolling.
99 ///
100 /// Default: 1.0
101 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
102 pub scroll_sensitivity: Option<f32>,
103 /// Whether to zoom the editor font size with the mouse wheel
104 /// while holding the primary modifier key (Cmd on macOS, Ctrl on other platforms).
105 ///
106 /// Default: false
107 pub mouse_wheel_zoom: Option<bool>,
108 /// Scroll sensitivity multiplier for fast scrolling. This multiplier is applied
109 /// to both the horizontal and vertical delta values while scrolling. Fast scrolling
110 /// happens when a user holds the alt or option key while scrolling.
111 ///
112 /// Default: 4.0
113 #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
114 pub fast_scroll_sensitivity: Option<f32>,
115 /// Settings for sticking scopes to the top of the editor.
116 ///
117 /// Default: sticky scroll is disabled
118 pub sticky_scroll: Option<StickyScrollContent>,
119 /// Whether the line numbers on editors gutter are relative or not.
120 /// When "enabled" shows relative number of buffer lines, when "wrapped" shows
121 /// relative number of display lines.
122 ///
123 /// Default: "disabled"
124 pub relative_line_numbers: Option<RelativeLineNumbers>,
125 /// When to populate a new search's query based on the text under the cursor.
126 ///
127 /// Default: always
128 pub seed_search_query_from_cursor: Option<SeedQuerySetting>,
129 pub use_smartcase_search: Option<bool>,
130 /// Determines the modifier to be used to add multiple cursors with the mouse. The open hover link mouse gestures will adapt such that it do not conflict with the multicursor modifier.
131 ///
132 /// Default: alt
133 pub multi_cursor_modifier: Option<MultiCursorModifier>,
134 /// Hide the values of variables in `private` files, as defined by the
135 /// private_files setting. This only changes the visual representation,
136 /// the values are still present in the file and can be selected / copied / pasted
137 ///
138 /// Default: false
139 pub redact_private_values: Option<bool>,
140
141 /// How many lines to expand the multibuffer excerpts by default
142 ///
143 /// Default: 3
144 pub expand_excerpt_lines: Option<u32>,
145
146 /// How many lines of context to provide in multibuffer excerpts by default
147 ///
148 /// Default: 2
149 pub excerpt_context_lines: Option<u32>,
150
151 /// Whether to enable middle-click paste on Linux
152 ///
153 /// Default: true
154 pub middle_click_paste: Option<bool>,
155
156 /// What to do when multibuffer is double clicked in some of its excerpts
157 /// (parts of singleton buffers).
158 ///
159 /// Default: select
160 pub double_click_in_multibuffer: Option<DoubleClickInMultibuffer>,
161 /// Whether the editor search results will loop
162 ///
163 /// Default: true
164 pub search_wrap: Option<bool>,
165
166 /// Defaults to use when opening a new buffer and project search items.
167 ///
168 /// Default: nothing is enabled
169 pub search: Option<SearchSettingsContent>,
170
171 /// Whether to automatically show a signature help pop-up or not.
172 ///
173 /// Default: false
174 pub auto_signature_help: Option<bool>,
175
176 /// Whether to show the signature help pop-up after completions or bracket pairs inserted.
177 ///
178 /// Default: false
179 pub show_signature_help_after_edits: Option<bool>,
180 /// The minimum APCA perceptual contrast to maintain when
181 /// rendering text over highlight backgrounds in the editor.
182 ///
183 /// Values range from 0 to 106. Set to 0 to disable adjustments.
184 /// Default: 45
185 #[schemars(range(min = 0, max = 106))]
186 pub minimum_contrast_for_highlights: Option<MinimumContrast>,
187
188 /// Whether to follow-up empty go to definition responses from the language server or not.
189 /// `FindAllReferences` allows to look up references of the same symbol instead.
190 /// `None` disables the fallback.
191 ///
192 /// Default: FindAllReferences
193 pub go_to_definition_fallback: Option<GoToDefinitionFallback>,
194
195 /// Jupyter REPL settings.
196 pub jupyter: Option<JupyterContent>,
197
198 /// Which level to use to filter out diagnostics displayed in the editor.
199 ///
200 /// Affects the editor rendering only, and does not interrupt
201 /// the functionality of diagnostics fetching and project diagnostics editor.
202 /// Which files containing diagnostic errors/warnings to mark in the tabs.
203 /// Diagnostics are only shown when file icons are also active.
204 ///
205 /// Shows all diagnostics if not specified.
206 ///
207 /// Default: warning
208 pub diagnostics_max_severity: Option<DiagnosticSeverityContent>,
209
210 /// Whether to show code action button at start of buffer line.
211 ///
212 /// Default: true
213 pub inline_code_actions: Option<bool>,
214
215 /// Drag and drop related settings
216 pub drag_and_drop_selection: Option<DragAndDropSelectionContent>,
217
218 /// Whether and how to display code lenses from language servers.
219 ///
220 /// Default: "off"
221 pub code_lens: Option<CodeLens>,
222
223 /// How to render LSP `textDocument/documentColor` colors in the editor.
224 ///
225 /// Default: [`DocumentColorsRenderMode::Inlay`]
226 pub lsp_document_colors: Option<DocumentColorsRenderMode>,
227 /// When to show the scrollbar in the completion menu.
228 /// This setting can take four values:
229 ///
230 /// 1. Show the scrollbar if there's important information or
231 /// follow the system's configured behavior
232 /// "auto"
233 /// 2. Match the system's configured behavior:
234 /// "system"
235 /// 3. Always show the scrollbar:
236 /// "always"
237 /// 4. Never show the scrollbar:
238 /// "never" (default)
239 pub completion_menu_scrollbar: Option<ShowScrollbar>,
240
241 /// Whether to align detail text in code completions context menus left or right.
242 ///
243 /// Default: left
244 pub completion_detail_alignment: Option<CompletionDetailAlignment>,
245
246 /// How to display diffs in the editor.
247 ///
248 /// Default: split
249 pub diff_view_style: Option<DiffViewStyle>,
250
251 /// The minimum width (in em-widths) at which the split diff view is used.
252 /// When the editor is narrower than this, the diff view automatically
253 /// switches to unified mode and switches back when the editor is wide
254 /// enough. Set to 0 to disable automatic switching.
255 ///
256 /// Default: 100
257 pub minimum_split_diff_width: Option<f32>,
258}
259
260#[derive(
261 Debug,
262 Clone,
263 Copy,
264 Serialize,
265 Deserialize,
266 JsonSchema,
267 MergeFrom,
268 PartialEq,
269 Eq,
270 strum::VariantArray,
271 strum::VariantNames,
272)]
273#[serde(rename_all = "snake_case")]
274pub enum RelativeLineNumbers {
275 Disabled,
276 Enabled,
277 Wrapped,
278}
279
280#[derive(
281 Debug,
282 Default,
283 Clone,
284 Copy,
285 Serialize,
286 Deserialize,
287 JsonSchema,
288 MergeFrom,
289 PartialEq,
290 Eq,
291 strum::VariantArray,
292 strum::VariantNames,
293)]
294#[serde(rename_all = "snake_case")]
295pub enum CompletionDetailAlignment {
296 #[default]
297 Left,
298 Right,
299}
300
301impl RelativeLineNumbers {
302 pub fn enabled(&self) -> bool {
303 match self {
304 RelativeLineNumbers::Enabled | RelativeLineNumbers::Wrapped => true,
305 RelativeLineNumbers::Disabled => false,
306 }
307 }
308 pub fn wrapped(&self) -> bool {
309 match self {
310 RelativeLineNumbers::Enabled | RelativeLineNumbers::Disabled => false,
311 RelativeLineNumbers::Wrapped => true,
312 }
313 }
314}
315
316// Toolbar related settings
317#[with_fallible_options]
318#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
319pub struct ToolbarContent {
320 /// Whether to display breadcrumbs in the editor toolbar.
321 ///
322 /// Default: true
323 pub breadcrumbs: Option<bool>,
324 /// Whether to display quick action buttons in the editor toolbar.
325 ///
326 /// Default: true
327 pub quick_actions: Option<bool>,
328 /// Whether to show the selections menu in the editor toolbar.
329 ///
330 /// Default: true
331 pub selections_menu: Option<bool>,
332 /// Whether to display Agent review buttons in the editor toolbar.
333 /// Only applicable while reviewing a file edited by the Agent.
334 ///
335 /// Default: true
336 pub agent_review: Option<bool>,
337 /// Whether to display code action buttons in the editor toolbar.
338 ///
339 /// Default: false
340 pub code_actions: Option<bool>,
341}
342
343/// Scrollbar related settings
344#[with_fallible_options]
345#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
346pub struct ScrollbarContent {
347 /// When to show the scrollbar in the editor.
348 ///
349 /// Default: auto
350 pub show: Option<ShowScrollbar>,
351 /// Whether to show git diff indicators in the scrollbar.
352 ///
353 /// Default: true
354 pub git_diff: Option<bool>,
355 /// Whether to show buffer search result indicators in the scrollbar.
356 ///
357 /// Default: true
358 pub search_results: Option<bool>,
359 /// Whether to show selected text occurrences in the scrollbar.
360 ///
361 /// Default: true
362 pub selected_text: Option<bool>,
363 /// Whether to show selected symbol occurrences in the scrollbar.
364 ///
365 /// Default: true
366 pub selected_symbol: Option<bool>,
367 /// Which diagnostic indicators to show in the scrollbar:
368 ///
369 /// Default: all
370 pub diagnostics: Option<ScrollbarDiagnostics>,
371 /// Whether to show cursor positions in the scrollbar.
372 ///
373 /// Default: true
374 pub cursors: Option<bool>,
375 /// Forcefully enable or disable the scrollbar for each axis
376 pub axes: Option<ScrollbarAxesContent>,
377}
378
379/// Sticky scroll related settings
380#[with_fallible_options]
381#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
382pub struct StickyScrollContent {
383 /// Whether sticky scroll is enabled.
384 ///
385 /// Default: false
386 pub enabled: Option<bool>,
387}
388
389/// Minimap related settings
390#[with_fallible_options]
391#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
392pub struct MinimapContent {
393 /// When to show the minimap in the editor.
394 ///
395 /// Default: never
396 pub show: Option<ShowMinimap>,
397
398 /// Where to show the minimap in the editor.
399 ///
400 /// Default: [`DisplayIn::ActiveEditor`]
401 pub display_in: Option<DisplayIn>,
402
403 /// When to show the minimap thumb.
404 ///
405 /// Default: always
406 pub thumb: Option<MinimapThumb>,
407
408 /// Defines the border style for the minimap's scrollbar thumb.
409 ///
410 /// Default: left_open
411 pub thumb_border: Option<MinimapThumbBorder>,
412
413 /// How to highlight the current line in the minimap.
414 ///
415 /// Default: inherits editor line highlights setting
416 pub current_line_highlight: Option<CurrentLineHighlight>,
417
418 /// Maximum number of columns to display in the minimap.
419 ///
420 /// Default: 80
421 pub max_width_columns: Option<num::NonZeroU32>,
422}
423
424/// Forcefully enable or disable the scrollbar for each axis
425#[with_fallible_options]
426#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
427pub struct ScrollbarAxesContent {
428 /// When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings.
429 ///
430 /// Default: true
431 pub horizontal: Option<bool>,
432
433 /// When false, forcefully disables the vertical scrollbar. Otherwise, obey other settings.
434 ///
435 /// Default: true
436 pub vertical: Option<bool>,
437}
438
439/// Gutter related settings
440#[with_fallible_options]
441#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
442pub struct GutterContent {
443 /// Whether to show line numbers in the gutter.
444 ///
445 /// Default: true
446 pub line_numbers: Option<bool>,
447 /// Minimum number of characters to reserve space for in the gutter.
448 ///
449 /// Default: 4
450 pub min_line_number_digits: Option<usize>,
451 /// Whether to show runnable buttons in the gutter.
452 ///
453 /// Default: true
454 pub runnables: Option<bool>,
455 /// Whether to show breakpoints in the gutter.
456 ///
457 /// Default: true
458 pub breakpoints: Option<bool>,
459 /// Whether to show bookmarks in the gutter.
460 ///
461 /// Default: true
462 pub bookmarks: Option<bool>,
463 /// Whether to show fold buttons in the gutter.
464 ///
465 /// Default: true
466 pub folds: Option<bool>,
467}
468
469/// Whether to display code lenses from language servers above code elements.
470#[derive(
471 Copy,
472 Clone,
473 Debug,
474 Default,
475 Serialize,
476 Deserialize,
477 PartialEq,
478 Eq,
479 JsonSchema,
480 MergeFrom,
481 strum::VariantArray,
482 strum::VariantNames,
483)]
484#[serde(rename_all = "snake_case")]
485pub enum CodeLens {
486 /// Do not query and display code lenses.
487 #[default]
488 Off,
489 /// Display code lenses from language servers above code elements.
490 On,
491 /// Display code lenses in the code action menu.
492 Menu,
493}
494
495impl CodeLens {
496 pub fn enabled(&self) -> bool {
497 self != &Self::Off
498 }
499
500 pub fn inline(&self) -> bool {
501 *self == Self::On
502 }
503
504 pub fn show_in_menu(&self) -> bool {
505 *self == Self::Menu
506 }
507}
508
509/// How to render LSP `textDocument/documentColor` colors in the editor.
510#[derive(
511 Debug,
512 Clone,
513 Copy,
514 Default,
515 Serialize,
516 Deserialize,
517 JsonSchema,
518 MergeFrom,
519 PartialEq,
520 Eq,
521 strum::VariantArray,
522 strum::VariantNames,
523)]
524#[serde(rename_all = "snake_case")]
525pub enum DocumentColorsRenderMode {
526 /// Do not query and render document colors.
527 None,
528 /// Render document colors as inlay hints near the color text.
529 #[default]
530 Inlay,
531 /// Draw a border around the color text.
532 Border,
533 /// Draw a background behind the color text.
534 Background,
535}
536
537#[derive(
538 Copy,
539 Clone,
540 Debug,
541 Serialize,
542 Deserialize,
543 PartialEq,
544 Eq,
545 JsonSchema,
546 MergeFrom,
547 strum::VariantArray,
548 strum::VariantNames,
549)]
550#[serde(rename_all = "snake_case")]
551pub enum CurrentLineHighlight {
552 // Don't highlight the current line.
553 None,
554 // Highlight the gutter area.
555 Gutter,
556 // Highlight the editor area.
557 Line,
558 // Highlight the full line.
559 All,
560}
561
562/// When to populate a new search's query based on the text under the cursor.
563#[derive(
564 Copy,
565 Clone,
566 Debug,
567 Serialize,
568 Deserialize,
569 PartialEq,
570 Eq,
571 JsonSchema,
572 MergeFrom,
573 strum::VariantArray,
574 strum::VariantNames,
575)]
576#[serde(rename_all = "snake_case")]
577pub enum SeedQuerySetting {
578 /// Always populate the search query with the word under the cursor.
579 Always,
580 /// Only populate the search query when there is text selected.
581 Selection,
582 /// Never populate the search query
583 Never,
584}
585
586/// What to do when multibuffer is double clicked in some of its excerpts (parts of singleton buffers).
587#[derive(
588 Default,
589 Copy,
590 Clone,
591 Debug,
592 Serialize,
593 Deserialize,
594 PartialEq,
595 Eq,
596 JsonSchema,
597 MergeFrom,
598 strum::VariantArray,
599 strum::VariantNames,
600)]
601#[serde(rename_all = "snake_case")]
602pub enum DoubleClickInMultibuffer {
603 /// Behave as a regular buffer and select the whole word.
604 #[default]
605 Select,
606 /// Open the excerpt clicked as a new buffer in the new tab, if no `alt` modifier was pressed during double click.
607 /// Otherwise, behave as a regular buffer and select the whole word.
608 Open,
609}
610
611/// When to show the minimap thumb.
612///
613/// Default: always
614#[derive(
615 Copy,
616 Clone,
617 Debug,
618 Default,
619 Serialize,
620 Deserialize,
621 JsonSchema,
622 MergeFrom,
623 PartialEq,
624 Eq,
625 strum::VariantArray,
626 strum::VariantNames,
627)]
628#[serde(rename_all = "snake_case")]
629pub enum MinimapThumb {
630 /// Show the minimap thumb only when the mouse is hovering over the minimap.
631 Hover,
632 /// Always show the minimap thumb.
633 #[default]
634 Always,
635}
636
637/// Defines the border style for the minimap's scrollbar thumb.
638///
639/// Default: left_open
640#[derive(
641 Copy,
642 Clone,
643 Debug,
644 Default,
645 Serialize,
646 Deserialize,
647 JsonSchema,
648 MergeFrom,
649 PartialEq,
650 Eq,
651 strum::VariantArray,
652 strum::VariantNames,
653)]
654#[serde(rename_all = "snake_case")]
655pub enum MinimapThumbBorder {
656 /// Displays a border on all sides of the thumb.
657 Full,
658 /// Displays a border on all sides except the left side of the thumb.
659 #[default]
660 LeftOpen,
661 /// Displays a border on all sides except the right side of the thumb.
662 RightOpen,
663 /// Displays a border only on the left side of the thumb.
664 LeftOnly,
665 /// Displays the thumb without any border.
666 None,
667}
668
669/// Which diagnostic indicators to show in the scrollbar.
670///
671/// Default: all
672#[derive(
673 Copy,
674 Clone,
675 Debug,
676 Serialize,
677 Deserialize,
678 JsonSchema,
679 MergeFrom,
680 PartialEq,
681 Eq,
682 strum::VariantArray,
683 strum::VariantNames,
684)]
685#[serde(rename_all = "lowercase")]
686pub enum ScrollbarDiagnostics {
687 /// Show all diagnostic levels: hint, information, warnings, error.
688 All,
689 /// Show only the following diagnostic levels: information, warning, error.
690 Information,
691 /// Show only the following diagnostic levels: warning, error.
692 Warning,
693 /// Show only the following diagnostic level: error.
694 Error,
695 /// Do not show diagnostics.
696 None,
697}
698
699/// The key to use for adding multiple cursors
700///
701/// Default: alt
702#[derive(
703 Copy,
704 Clone,
705 Debug,
706 Serialize,
707 Deserialize,
708 JsonSchema,
709 MergeFrom,
710 PartialEq,
711 Eq,
712 strum::VariantArray,
713 strum::VariantNames,
714)]
715#[serde(rename_all = "snake_case")]
716pub enum MultiCursorModifier {
717 Alt,
718 #[serde(alias = "cmd", alias = "ctrl")]
719 CmdOrCtrl,
720}
721
722/// Whether the editor will scroll beyond the last line.
723///
724/// Default: one_page
725#[derive(
726 Copy,
727 Clone,
728 Debug,
729 Serialize,
730 Deserialize,
731 JsonSchema,
732 MergeFrom,
733 PartialEq,
734 Eq,
735 strum::VariantArray,
736 strum::VariantNames,
737)]
738#[serde(rename_all = "snake_case")]
739pub enum ScrollBeyondLastLine {
740 /// The editor will not scroll beyond the last line.
741 Off,
742
743 /// The editor will scroll beyond the last line by one page.
744 OnePage,
745
746 /// The editor will scroll beyond the last line by the same number of lines as vertical_scroll_margin.
747 VerticalScrollMargin,
748}
749
750/// The shape of a selection cursor.
751#[derive(
752 Copy,
753 Clone,
754 Debug,
755 Default,
756 Serialize,
757 Deserialize,
758 PartialEq,
759 Eq,
760 JsonSchema,
761 MergeFrom,
762 strum::VariantArray,
763 strum::VariantNames,
764)]
765#[serde(rename_all = "snake_case")]
766pub enum CursorShape {
767 /// A vertical bar
768 #[default]
769 Bar,
770 /// A block that surrounds the following character
771 Block,
772 /// An underline that runs along the following character
773 Underline,
774 /// A box drawn around the following character
775 Hollow,
776}
777
778/// What to do when go to definition yields no results.
779#[derive(
780 Copy,
781 Clone,
782 Debug,
783 Default,
784 Serialize,
785 Deserialize,
786 PartialEq,
787 Eq,
788 JsonSchema,
789 MergeFrom,
790 strum::VariantArray,
791 strum::VariantNames,
792)]
793#[serde(rename_all = "snake_case")]
794pub enum GoToDefinitionFallback {
795 /// Disables the fallback.
796 None,
797 /// Looks up references of the same symbol instead.
798 #[default]
799 FindAllReferences,
800}
801
802/// Determines when the mouse cursor should be hidden in an editor or input box.
803///
804/// Default: on_typing_and_movement
805#[derive(
806 Copy,
807 Clone,
808 Debug,
809 Default,
810 Serialize,
811 Deserialize,
812 PartialEq,
813 Eq,
814 JsonSchema,
815 MergeFrom,
816 strum::VariantArray,
817 strum::VariantNames,
818)]
819#[serde(rename_all = "snake_case")]
820pub enum HideMouseMode {
821 /// Never hide the mouse cursor
822 Never,
823 /// Hide only when typing
824 OnTyping,
825 /// Hide on both typing and cursor movement
826 #[default]
827 OnTypingAndMovement,
828}
829
830/// Determines how snippets are sorted relative to other completion items.
831///
832/// Default: inline
833#[derive(
834 Copy,
835 Clone,
836 Debug,
837 Default,
838 Serialize,
839 Deserialize,
840 PartialEq,
841 Eq,
842 JsonSchema,
843 MergeFrom,
844 strum::VariantArray,
845 strum::VariantNames,
846)]
847#[serde(rename_all = "snake_case")]
848pub enum SnippetSortOrder {
849 /// Place snippets at the top of the completion list
850 Top,
851 /// Sort snippets normally using the default comparison logic
852 #[default]
853 Inline,
854 /// Place snippets at the bottom of the completion list
855 Bottom,
856 /// Do not show snippets in the completion list
857 None,
858}
859
860/// How to display diffs in the editor.
861///
862/// Default: unified
863#[derive(
864 Copy,
865 Clone,
866 Debug,
867 Default,
868 PartialEq,
869 Eq,
870 Serialize,
871 Deserialize,
872 JsonSchema,
873 MergeFrom,
874 strum::Display,
875 strum::EnumIter,
876 strum::VariantArray,
877 strum::VariantNames,
878)]
879#[serde(rename_all = "snake_case")]
880pub enum DiffViewStyle {
881 /// Show diffs in a single unified view.
882 Unified,
883 /// Show diffs in a split view.
884 #[default]
885 Split,
886}
887
888/// Default options for buffer and project search items.
889#[with_fallible_options]
890#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
891pub struct SearchSettingsContent {
892 /// Whether to show the project search button in the status bar.
893 pub button: Option<bool>,
894 /// Whether to only match on whole words.
895 pub whole_word: Option<bool>,
896 /// Whether to match case sensitively.
897 pub case_sensitive: Option<bool>,
898 /// Whether to include gitignored files in search results.
899 pub include_ignored: Option<bool>,
900 /// Whether to interpret the search query as a regular expression.
901 pub regex: Option<bool>,
902 /// Whether to center the cursor on each search match when navigating.
903 pub center_on_match: Option<bool>,
904}
905
906#[with_fallible_options]
907#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
908#[serde(rename_all = "snake_case")]
909pub struct JupyterContent {
910 /// Whether the Jupyter feature is enabled.
911 ///
912 /// Default: true
913 pub enabled: Option<bool>,
914
915 /// Default kernels to select for each language.
916 ///
917 /// Default: `{}`
918 pub kernel_selections: Option<HashMap<String, String>>,
919}
920
921/// Whether to allow drag and drop text selection in buffer.
922#[with_fallible_options]
923#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
924pub struct DragAndDropSelectionContent {
925 /// When true, enables drag and drop text selection in buffer.
926 ///
927 /// Default: true
928 pub enabled: Option<bool>,
929
930 /// The delay in milliseconds that must elapse before drag and drop is allowed. Otherwise, a new text selection is created.
931 ///
932 /// Default: 300
933 pub delay: Option<DelayMs>,
934}
935
936/// When to show the minimap in the editor.
937///
938/// Default: never
939#[derive(
940 Copy,
941 Clone,
942 Debug,
943 Default,
944 Serialize,
945 Deserialize,
946 JsonSchema,
947 MergeFrom,
948 PartialEq,
949 Eq,
950 strum::VariantArray,
951 strum::VariantNames,
952)]
953#[serde(rename_all = "snake_case")]
954pub enum ShowMinimap {
955 /// Follow the visibility of the scrollbar.
956 Auto,
957 /// Always show the minimap.
958 Always,
959 /// Never show the minimap.
960 #[default]
961 Never,
962}
963
964/// Where to show the minimap in the editor.
965///
966/// Default: all_editors
967#[derive(
968 Copy,
969 Clone,
970 Debug,
971 Default,
972 Serialize,
973 Deserialize,
974 JsonSchema,
975 MergeFrom,
976 PartialEq,
977 Eq,
978 strum::VariantArray,
979 strum::VariantNames,
980)]
981#[serde(rename_all = "snake_case")]
982pub enum DisplayIn {
983 /// Show on all open editors.
984 AllEditors,
985 /// Show the minimap on the active editor only.
986 #[default]
987 ActiveEditor,
988}
989
990/// Minimum APCA perceptual contrast for text over highlight backgrounds.
991///
992/// Valid range: 0.0 to 106.0
993/// Default: 45.0
994#[derive(
995 Clone,
996 Copy,
997 Debug,
998 Serialize,
999 Deserialize,
1000 JsonSchema,
1001 MergeFrom,
1002 PartialEq,
1003 PartialOrd,
1004 derive_more::FromStr,
1005)]
1006#[serde(transparent)]
1007pub struct MinimumContrast(
1008 #[serde(serialize_with = "crate::serialize_f32_with_two_decimal_places")] pub f32,
1009);
1010
1011impl Display for MinimumContrast {
1012 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1013 write!(f, "{:.1}", self.0)
1014 }
1015}
1016
1017impl From<f32> for MinimumContrast {
1018 fn from(x: f32) -> Self {
1019 Self(x)
1020 }
1021}
1022
1023/// Opacity of the inactive panes. 0 means transparent, 1 means opaque.
1024///
1025/// Valid range: 0.0 to 1.0
1026/// Default: 1.0
1027#[derive(
1028 Clone,
1029 Copy,
1030 Debug,
1031 Serialize,
1032 Deserialize,
1033 JsonSchema,
1034 MergeFrom,
1035 PartialEq,
1036 PartialOrd,
1037 derive_more::FromStr,
1038)]
1039#[serde(transparent)]
1040pub struct InactiveOpacity(
1041 #[serde(serialize_with = "serialize_f32_with_two_decimal_places")] pub f32,
1042);
1043
1044impl Display for InactiveOpacity {
1045 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1046 write!(f, "{:.1}", self.0)
1047 }
1048}
1049
1050impl From<f32> for InactiveOpacity {
1051 fn from(x: f32) -> Self {
1052 Self(x)
1053 }
1054}
1055
1056/// Centered layout related setting (left/right).
1057///
1058/// Valid range: 0.0 to 0.4
1059/// Default: 2.0
1060#[derive(
1061 Clone,
1062 Copy,
1063 Debug,
1064 Serialize,
1065 Deserialize,
1066 MergeFrom,
1067 PartialEq,
1068 PartialOrd,
1069 derive_more::FromStr,
1070)]
1071#[serde(transparent)]
1072pub struct CenteredPaddingSettings(
1073 #[serde(serialize_with = "serialize_f32_with_two_decimal_places")] pub f32,
1074);
1075
1076impl CenteredPaddingSettings {
1077 pub const MIN_PADDING: f32 = 0.0;
1078 // This is an f64 so serde_json can give a type hint without random numbers in the back
1079 pub const DEFAULT_PADDING: f64 = 0.2;
1080 pub const MAX_PADDING: f32 = 0.4;
1081}
1082
1083impl Display for CenteredPaddingSettings {
1084 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1085 write!(f, "{:.2}", self.0)
1086 }
1087}
1088
1089impl From<f32> for CenteredPaddingSettings {
1090 fn from(x: f32) -> Self {
1091 Self(x)
1092 }
1093}
1094
1095impl Default for CenteredPaddingSettings {
1096 fn default() -> Self {
1097 Self(Self::DEFAULT_PADDING as f32)
1098 }
1099}
1100
1101impl schemars::JsonSchema for CenteredPaddingSettings {
1102 fn schema_name() -> std::borrow::Cow<'static, str> {
1103 "CenteredPaddingSettings".into()
1104 }
1105
1106 fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
1107 use schemars::json_schema;
1108 json_schema!({
1109 "type": "number",
1110 "minimum": Self::MIN_PADDING,
1111 "maximum": Self::MAX_PADDING,
1112 "default": Self::DEFAULT_PADDING,
1113 "description": "Centered layout related setting (left/right)."
1114 })
1115 }
1116}