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