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