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 fold buttons in the gutter.
 455    ///
 456    /// Default: true
 457    pub folds: Option<bool>,
 458}
 459
 460/// How to render LSP `textDocument/documentColor` colors in the editor.
 461#[derive(
 462    Copy,
 463    Clone,
 464    Debug,
 465    Default,
 466    Serialize,
 467    Deserialize,
 468    PartialEq,
 469    Eq,
 470    JsonSchema,
 471    MergeFrom,
 472    strum::VariantArray,
 473    strum::VariantNames,
 474)]
 475#[serde(rename_all = "snake_case")]
 476pub enum DocumentColorsRenderMode {
 477    /// Do not query and render document colors.
 478    None,
 479    /// Render document colors as inlay hints near the color text.
 480    #[default]
 481    Inlay,
 482    /// Draw a border around the color text.
 483    Border,
 484    /// Draw a background behind the color text.
 485    Background,
 486}
 487
 488#[derive(
 489    Copy,
 490    Clone,
 491    Debug,
 492    Serialize,
 493    Deserialize,
 494    PartialEq,
 495    Eq,
 496    JsonSchema,
 497    MergeFrom,
 498    strum::VariantArray,
 499    strum::VariantNames,
 500)]
 501#[serde(rename_all = "snake_case")]
 502pub enum CurrentLineHighlight {
 503    // Don't highlight the current line.
 504    None,
 505    // Highlight the gutter area.
 506    Gutter,
 507    // Highlight the editor area.
 508    Line,
 509    // Highlight the full line.
 510    All,
 511}
 512
 513/// When to populate a new search's query based on the text under the cursor.
 514#[derive(
 515    Copy,
 516    Clone,
 517    Debug,
 518    Serialize,
 519    Deserialize,
 520    PartialEq,
 521    Eq,
 522    JsonSchema,
 523    MergeFrom,
 524    strum::VariantArray,
 525    strum::VariantNames,
 526)]
 527#[serde(rename_all = "snake_case")]
 528pub enum SeedQuerySetting {
 529    /// Always populate the search query with the word under the cursor.
 530    Always,
 531    /// Only populate the search query when there is text selected.
 532    Selection,
 533    /// Never populate the search query
 534    Never,
 535}
 536
 537/// What to do when multibuffer is double clicked in some of its excerpts (parts of singleton buffers).
 538#[derive(
 539    Default,
 540    Copy,
 541    Clone,
 542    Debug,
 543    Serialize,
 544    Deserialize,
 545    PartialEq,
 546    Eq,
 547    JsonSchema,
 548    MergeFrom,
 549    strum::VariantArray,
 550    strum::VariantNames,
 551)]
 552#[serde(rename_all = "snake_case")]
 553pub enum DoubleClickInMultibuffer {
 554    /// Behave as a regular buffer and select the whole word.
 555    #[default]
 556    Select,
 557    /// Open the excerpt clicked as a new buffer in the new tab, if no `alt` modifier was pressed during double click.
 558    /// Otherwise, behave as a regular buffer and select the whole word.
 559    Open,
 560}
 561
 562/// When to show the minimap thumb.
 563///
 564/// Default: always
 565#[derive(
 566    Copy,
 567    Clone,
 568    Debug,
 569    Default,
 570    Serialize,
 571    Deserialize,
 572    JsonSchema,
 573    MergeFrom,
 574    PartialEq,
 575    Eq,
 576    strum::VariantArray,
 577    strum::VariantNames,
 578)]
 579#[serde(rename_all = "snake_case")]
 580pub enum MinimapThumb {
 581    /// Show the minimap thumb only when the mouse is hovering over the minimap.
 582    Hover,
 583    /// Always show the minimap thumb.
 584    #[default]
 585    Always,
 586}
 587
 588/// Defines the border style for the minimap's scrollbar thumb.
 589///
 590/// Default: left_open
 591#[derive(
 592    Copy,
 593    Clone,
 594    Debug,
 595    Default,
 596    Serialize,
 597    Deserialize,
 598    JsonSchema,
 599    MergeFrom,
 600    PartialEq,
 601    Eq,
 602    strum::VariantArray,
 603    strum::VariantNames,
 604)]
 605#[serde(rename_all = "snake_case")]
 606pub enum MinimapThumbBorder {
 607    /// Displays a border on all sides of the thumb.
 608    Full,
 609    /// Displays a border on all sides except the left side of the thumb.
 610    #[default]
 611    LeftOpen,
 612    /// Displays a border on all sides except the right side of the thumb.
 613    RightOpen,
 614    /// Displays a border only on the left side of the thumb.
 615    LeftOnly,
 616    /// Displays the thumb without any border.
 617    None,
 618}
 619
 620/// Which diagnostic indicators to show in the scrollbar.
 621///
 622/// Default: all
 623#[derive(
 624    Copy,
 625    Clone,
 626    Debug,
 627    Serialize,
 628    Deserialize,
 629    JsonSchema,
 630    MergeFrom,
 631    PartialEq,
 632    Eq,
 633    strum::VariantArray,
 634    strum::VariantNames,
 635)]
 636#[serde(rename_all = "lowercase")]
 637pub enum ScrollbarDiagnostics {
 638    /// Show all diagnostic levels: hint, information, warnings, error.
 639    All,
 640    /// Show only the following diagnostic levels: information, warning, error.
 641    Information,
 642    /// Show only the following diagnostic levels: warning, error.
 643    Warning,
 644    /// Show only the following diagnostic level: error.
 645    Error,
 646    /// Do not show diagnostics.
 647    None,
 648}
 649
 650/// The key to use for adding multiple cursors
 651///
 652/// Default: alt
 653#[derive(
 654    Copy,
 655    Clone,
 656    Debug,
 657    Serialize,
 658    Deserialize,
 659    JsonSchema,
 660    MergeFrom,
 661    PartialEq,
 662    Eq,
 663    strum::VariantArray,
 664    strum::VariantNames,
 665)]
 666#[serde(rename_all = "snake_case")]
 667pub enum MultiCursorModifier {
 668    Alt,
 669    #[serde(alias = "cmd", alias = "ctrl")]
 670    CmdOrCtrl,
 671}
 672
 673/// Whether the editor will scroll beyond the last line.
 674///
 675/// Default: one_page
 676#[derive(
 677    Copy,
 678    Clone,
 679    Debug,
 680    Serialize,
 681    Deserialize,
 682    JsonSchema,
 683    MergeFrom,
 684    PartialEq,
 685    Eq,
 686    strum::VariantArray,
 687    strum::VariantNames,
 688)]
 689#[serde(rename_all = "snake_case")]
 690pub enum ScrollBeyondLastLine {
 691    /// The editor will not scroll beyond the last line.
 692    Off,
 693
 694    /// The editor will scroll beyond the last line by one page.
 695    OnePage,
 696
 697    /// The editor will scroll beyond the last line by the same number of lines as vertical_scroll_margin.
 698    VerticalScrollMargin,
 699}
 700
 701/// The shape of a selection cursor.
 702#[derive(
 703    Copy,
 704    Clone,
 705    Debug,
 706    Default,
 707    Serialize,
 708    Deserialize,
 709    PartialEq,
 710    Eq,
 711    JsonSchema,
 712    MergeFrom,
 713    strum::VariantArray,
 714    strum::VariantNames,
 715)]
 716#[serde(rename_all = "snake_case")]
 717pub enum CursorShape {
 718    /// A vertical bar
 719    #[default]
 720    Bar,
 721    /// A block that surrounds the following character
 722    Block,
 723    /// An underline that runs along the following character
 724    Underline,
 725    /// A box drawn around the following character
 726    Hollow,
 727}
 728
 729/// What to do when go to definition yields no results.
 730#[derive(
 731    Copy,
 732    Clone,
 733    Debug,
 734    Default,
 735    Serialize,
 736    Deserialize,
 737    PartialEq,
 738    Eq,
 739    JsonSchema,
 740    MergeFrom,
 741    strum::VariantArray,
 742    strum::VariantNames,
 743)]
 744#[serde(rename_all = "snake_case")]
 745pub enum GoToDefinitionFallback {
 746    /// Disables the fallback.
 747    None,
 748    /// Looks up references of the same symbol instead.
 749    #[default]
 750    FindAllReferences,
 751}
 752
 753/// Determines when the mouse cursor should be hidden in an editor or input box.
 754///
 755/// Default: on_typing_and_movement
 756#[derive(
 757    Copy,
 758    Clone,
 759    Debug,
 760    Default,
 761    Serialize,
 762    Deserialize,
 763    PartialEq,
 764    Eq,
 765    JsonSchema,
 766    MergeFrom,
 767    strum::VariantArray,
 768    strum::VariantNames,
 769)]
 770#[serde(rename_all = "snake_case")]
 771pub enum HideMouseMode {
 772    /// Never hide the mouse cursor
 773    Never,
 774    /// Hide only when typing
 775    OnTyping,
 776    /// Hide on both typing and cursor movement
 777    #[default]
 778    OnTypingAndMovement,
 779}
 780
 781/// Determines how snippets are sorted relative to other completion items.
 782///
 783/// Default: inline
 784#[derive(
 785    Copy,
 786    Clone,
 787    Debug,
 788    Default,
 789    Serialize,
 790    Deserialize,
 791    PartialEq,
 792    Eq,
 793    JsonSchema,
 794    MergeFrom,
 795    strum::VariantArray,
 796    strum::VariantNames,
 797)]
 798#[serde(rename_all = "snake_case")]
 799pub enum SnippetSortOrder {
 800    /// Place snippets at the top of the completion list
 801    Top,
 802    /// Sort snippets normally using the default comparison logic
 803    #[default]
 804    Inline,
 805    /// Place snippets at the bottom of the completion list
 806    Bottom,
 807    /// Do not show snippets in the completion list
 808    None,
 809}
 810
 811/// How to display diffs in the editor.
 812///
 813/// Default: unified
 814#[derive(
 815    Copy,
 816    Clone,
 817    Debug,
 818    Default,
 819    PartialEq,
 820    Eq,
 821    Serialize,
 822    Deserialize,
 823    JsonSchema,
 824    MergeFrom,
 825    strum::Display,
 826    strum::EnumIter,
 827    strum::VariantArray,
 828    strum::VariantNames,
 829)]
 830#[serde(rename_all = "snake_case")]
 831pub enum DiffViewStyle {
 832    /// Show diffs in a single unified view.
 833    Unified,
 834    /// Show diffs in a split view.
 835    #[default]
 836    Split,
 837}
 838
 839/// Default options for buffer and project search items.
 840#[with_fallible_options]
 841#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 842pub struct SearchSettingsContent {
 843    /// Whether to show the project search button in the status bar.
 844    pub button: Option<bool>,
 845    /// Whether to only match on whole words.
 846    pub whole_word: Option<bool>,
 847    /// Whether to match case sensitively.
 848    pub case_sensitive: Option<bool>,
 849    /// Whether to include gitignored files in search results.
 850    pub include_ignored: Option<bool>,
 851    /// Whether to interpret the search query as a regular expression.
 852    pub regex: Option<bool>,
 853    /// Whether to center the cursor on each search match when navigating.
 854    pub center_on_match: Option<bool>,
 855}
 856
 857#[with_fallible_options]
 858#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
 859#[serde(rename_all = "snake_case")]
 860pub struct JupyterContent {
 861    /// Whether the Jupyter feature is enabled.
 862    ///
 863    /// Default: true
 864    pub enabled: Option<bool>,
 865
 866    /// Default kernels to select for each language.
 867    ///
 868    /// Default: `{}`
 869    pub kernel_selections: Option<HashMap<String, String>>,
 870}
 871
 872/// Whether to allow drag and drop text selection in buffer.
 873#[with_fallible_options]
 874#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 875pub struct DragAndDropSelectionContent {
 876    /// When true, enables drag and drop text selection in buffer.
 877    ///
 878    /// Default: true
 879    pub enabled: Option<bool>,
 880
 881    /// The delay in milliseconds that must elapse before drag and drop is allowed. Otherwise, a new text selection is created.
 882    ///
 883    /// Default: 300
 884    pub delay: Option<DelayMs>,
 885}
 886
 887/// When to show the minimap in the editor.
 888///
 889/// Default: never
 890#[derive(
 891    Copy,
 892    Clone,
 893    Debug,
 894    Default,
 895    Serialize,
 896    Deserialize,
 897    JsonSchema,
 898    MergeFrom,
 899    PartialEq,
 900    Eq,
 901    strum::VariantArray,
 902    strum::VariantNames,
 903)]
 904#[serde(rename_all = "snake_case")]
 905pub enum ShowMinimap {
 906    /// Follow the visibility of the scrollbar.
 907    Auto,
 908    /// Always show the minimap.
 909    Always,
 910    /// Never show the minimap.
 911    #[default]
 912    Never,
 913}
 914
 915/// Where to show the minimap in the editor.
 916///
 917/// Default: all_editors
 918#[derive(
 919    Copy,
 920    Clone,
 921    Debug,
 922    Default,
 923    Serialize,
 924    Deserialize,
 925    JsonSchema,
 926    MergeFrom,
 927    PartialEq,
 928    Eq,
 929    strum::VariantArray,
 930    strum::VariantNames,
 931)]
 932#[serde(rename_all = "snake_case")]
 933pub enum DisplayIn {
 934    /// Show on all open editors.
 935    AllEditors,
 936    /// Show the minimap on the active editor only.
 937    #[default]
 938    ActiveEditor,
 939}
 940
 941/// Minimum APCA perceptual contrast for text over highlight backgrounds.
 942///
 943/// Valid range: 0.0 to 106.0
 944/// Default: 45.0
 945#[derive(
 946    Clone,
 947    Copy,
 948    Debug,
 949    Serialize,
 950    Deserialize,
 951    JsonSchema,
 952    MergeFrom,
 953    PartialEq,
 954    PartialOrd,
 955    derive_more::FromStr,
 956)]
 957#[serde(transparent)]
 958pub struct MinimumContrast(
 959    #[serde(serialize_with = "crate::serialize_f32_with_two_decimal_places")] pub f32,
 960);
 961
 962impl Display for MinimumContrast {
 963    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 964        write!(f, "{:.1}", self.0)
 965    }
 966}
 967
 968impl From<f32> for MinimumContrast {
 969    fn from(x: f32) -> Self {
 970        Self(x)
 971    }
 972}
 973
 974/// Opacity of the inactive panes. 0 means transparent, 1 means opaque.
 975///
 976/// Valid range: 0.0 to 1.0
 977/// Default: 1.0
 978#[derive(
 979    Clone,
 980    Copy,
 981    Debug,
 982    Serialize,
 983    Deserialize,
 984    JsonSchema,
 985    MergeFrom,
 986    PartialEq,
 987    PartialOrd,
 988    derive_more::FromStr,
 989)]
 990#[serde(transparent)]
 991pub struct InactiveOpacity(
 992    #[serde(serialize_with = "serialize_f32_with_two_decimal_places")] pub f32,
 993);
 994
 995impl Display for InactiveOpacity {
 996    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 997        write!(f, "{:.1}", self.0)
 998    }
 999}
1000
1001impl From<f32> for InactiveOpacity {
1002    fn from(x: f32) -> Self {
1003        Self(x)
1004    }
1005}
1006
1007/// Centered layout related setting (left/right).
1008///
1009/// Valid range: 0.0 to 0.4
1010/// Default: 2.0
1011#[derive(
1012    Clone,
1013    Copy,
1014    Debug,
1015    Serialize,
1016    Deserialize,
1017    MergeFrom,
1018    PartialEq,
1019    PartialOrd,
1020    derive_more::FromStr,
1021)]
1022#[serde(transparent)]
1023pub struct CenteredPaddingSettings(
1024    #[serde(serialize_with = "serialize_f32_with_two_decimal_places")] pub f32,
1025);
1026
1027impl CenteredPaddingSettings {
1028    pub const MIN_PADDING: f32 = 0.0;
1029    // This is an f64 so serde_json can give a type hint without random numbers in the back
1030    pub const DEFAULT_PADDING: f64 = 0.2;
1031    pub const MAX_PADDING: f32 = 0.4;
1032}
1033
1034impl Display for CenteredPaddingSettings {
1035    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1036        write!(f, "{:.2}", self.0)
1037    }
1038}
1039
1040impl From<f32> for CenteredPaddingSettings {
1041    fn from(x: f32) -> Self {
1042        Self(x)
1043    }
1044}
1045
1046impl Default for CenteredPaddingSettings {
1047    fn default() -> Self {
1048        Self(Self::DEFAULT_PADDING as f32)
1049    }
1050}
1051
1052impl schemars::JsonSchema for CenteredPaddingSettings {
1053    fn schema_name() -> std::borrow::Cow<'static, str> {
1054        "CenteredPaddingSettings".into()
1055    }
1056
1057    fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
1058        use schemars::json_schema;
1059        json_schema!({
1060            "type": "number",
1061            "minimum": Self::MIN_PADDING,
1062            "maximum": Self::MAX_PADDING,
1063            "default": Self::DEFAULT_PADDING,
1064            "description": "Centered layout related setting (left/right)."
1065        })
1066    }
1067}