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