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