editor.rs

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