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