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