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