editor.rs

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