editor.rs

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