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