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