editor_settings.rs

  1use gpui::App;
  2use language::CursorShape;
  3use project::project_settings::DiagnosticSeverity;
  4use schemars::JsonSchema;
  5use serde::{Deserialize, Serialize};
  6use settings::{Settings, SettingsSources, VsCodeSettings};
  7use util::serde::default_true;
  8
  9/// Imports from the VSCode settings at
 10/// https://code.visualstudio.com/docs/reference/default-settings
 11#[derive(Deserialize, Clone)]
 12pub struct EditorSettings {
 13    pub cursor_blink: bool,
 14    pub cursor_shape: Option<CursorShape>,
 15    pub current_line_highlight: CurrentLineHighlight,
 16    pub selection_highlight: bool,
 17    pub lsp_highlight_debounce: u64,
 18    pub hover_popover_enabled: bool,
 19    pub hover_popover_delay: u64,
 20    pub toolbar: Toolbar,
 21    pub scrollbar: Scrollbar,
 22    pub minimap: Minimap,
 23    pub gutter: Gutter,
 24    pub scroll_beyond_last_line: ScrollBeyondLastLine,
 25    pub vertical_scroll_margin: f32,
 26    pub autoscroll_on_clicks: bool,
 27    pub horizontal_scroll_margin: f32,
 28    pub scroll_sensitivity: f32,
 29    pub fast_scroll_sensitivity: f32,
 30    pub relative_line_numbers: bool,
 31    pub seed_search_query_from_cursor: SeedQuerySetting,
 32    pub use_smartcase_search: bool,
 33    pub multi_cursor_modifier: MultiCursorModifier,
 34    pub redact_private_values: bool,
 35    pub expand_excerpt_lines: u32,
 36    pub middle_click_paste: bool,
 37    #[serde(default)]
 38    pub double_click_in_multibuffer: DoubleClickInMultibuffer,
 39    pub search_wrap: bool,
 40    #[serde(default)]
 41    pub search: SearchSettings,
 42    pub auto_signature_help: bool,
 43    pub show_signature_help_after_edits: bool,
 44    #[serde(default)]
 45    pub go_to_definition_fallback: GoToDefinitionFallback,
 46    pub jupyter: Jupyter,
 47    pub hide_mouse: Option<HideMouseMode>,
 48    pub snippet_sort_order: SnippetSortOrder,
 49    #[serde(default)]
 50    pub diagnostics_max_severity: Option<DiagnosticSeverity>,
 51    pub inline_code_actions: bool,
 52    pub drag_and_drop_selection: bool,
 53}
 54
 55#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
 56#[serde(rename_all = "snake_case")]
 57pub enum CurrentLineHighlight {
 58    // Don't highlight the current line.
 59    None,
 60    // Highlight the gutter area.
 61    Gutter,
 62    // Highlight the editor area.
 63    Line,
 64    // Highlight the full line.
 65    All,
 66}
 67
 68/// When to populate a new search's query based on the text under the cursor.
 69#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
 70#[serde(rename_all = "snake_case")]
 71pub enum SeedQuerySetting {
 72    /// Always populate the search query with the word under the cursor.
 73    Always,
 74    /// Only populate the search query when there is text selected.
 75    Selection,
 76    /// Never populate the search query
 77    Never,
 78}
 79
 80/// What to do when multibuffer is double clicked in some of its excerpts (parts of singleton buffers).
 81#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
 82#[serde(rename_all = "snake_case")]
 83pub enum DoubleClickInMultibuffer {
 84    /// Behave as a regular buffer and select the whole word.
 85    #[default]
 86    Select,
 87    /// Open the excerpt clicked as a new buffer in the new tab, if no `alt` modifier was pressed during double click.
 88    /// Otherwise, behave as a regular buffer and select the whole word.
 89    Open,
 90}
 91
 92#[derive(Debug, Clone, Deserialize)]
 93pub struct Jupyter {
 94    /// Whether the Jupyter feature is enabled.
 95    ///
 96    /// Default: true
 97    pub enabled: bool,
 98}
 99
100#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
101#[serde(rename_all = "snake_case")]
102pub struct JupyterContent {
103    /// Whether the Jupyter feature is enabled.
104    ///
105    /// Default: true
106    pub enabled: Option<bool>,
107}
108
109#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
110pub struct Toolbar {
111    pub breadcrumbs: bool,
112    pub quick_actions: bool,
113    pub selections_menu: bool,
114    pub agent_review: bool,
115    pub code_actions: bool,
116}
117
118#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
119pub struct Scrollbar {
120    pub show: ShowScrollbar,
121    pub git_diff: bool,
122    pub selected_text: bool,
123    pub selected_symbol: bool,
124    pub search_results: bool,
125    pub diagnostics: ScrollbarDiagnostics,
126    pub cursors: bool,
127    pub axes: ScrollbarAxes,
128}
129
130#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
131pub struct Minimap {
132    pub show: ShowMinimap,
133    pub thumb: MinimapThumb,
134    pub thumb_border: MinimapThumbBorder,
135    pub current_line_highlight: Option<CurrentLineHighlight>,
136}
137
138impl Minimap {
139    pub fn minimap_enabled(&self) -> bool {
140        self.show != ShowMinimap::Never
141    }
142
143    pub fn with_show_override(self) -> Self {
144        Self {
145            show: ShowMinimap::Always,
146            ..self
147        }
148    }
149}
150
151#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
152pub struct Gutter {
153    pub min_line_number_digits: usize,
154    pub line_numbers: bool,
155    pub runnables: bool,
156    pub breakpoints: bool,
157    pub folds: bool,
158}
159
160/// When to show the scrollbar in the editor.
161///
162/// Default: auto
163#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
164#[serde(rename_all = "snake_case")]
165pub enum ShowScrollbar {
166    /// Show the scrollbar if there's important information or
167    /// follow the system's configured behavior.
168    Auto,
169    /// Match the system's configured behavior.
170    System,
171    /// Always show the scrollbar.
172    Always,
173    /// Never show the scrollbar.
174    Never,
175}
176
177/// When to show the minimap in the editor.
178///
179/// Default: never
180#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
181#[serde(rename_all = "snake_case")]
182pub enum ShowMinimap {
183    /// Follow the visibility of the scrollbar.
184    Auto,
185    /// Always show the minimap.
186    Always,
187    /// Never show the minimap.
188    #[default]
189    Never,
190}
191
192/// When to show the minimap thumb.
193///
194/// Default: always
195#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
196#[serde(rename_all = "snake_case")]
197pub enum MinimapThumb {
198    /// Show the minimap thumb only when the mouse is hovering over the minimap.
199    Hover,
200    /// Always show the minimap thumb.
201    #[default]
202    Always,
203}
204
205/// Defines the border style for the minimap's scrollbar thumb.
206///
207/// Default: left_open
208#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
209#[serde(rename_all = "snake_case")]
210pub enum MinimapThumbBorder {
211    /// Displays a border on all sides of the thumb.
212    Full,
213    /// Displays a border on all sides except the left side of the thumb.
214    #[default]
215    LeftOpen,
216    /// Displays a border on all sides except the right side of the thumb.
217    RightOpen,
218    /// Displays a border only on the left side of the thumb.
219    LeftOnly,
220    /// Displays the thumb without any border.
221    None,
222}
223
224/// Forcefully enable or disable the scrollbar for each axis
225#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
226#[serde(rename_all = "lowercase")]
227pub struct ScrollbarAxes {
228    /// When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings.
229    ///
230    /// Default: true
231    pub horizontal: bool,
232
233    /// When false, forcefully disables the vertical scrollbar. Otherwise, obey other settings.
234    ///
235    /// Default: true
236    pub vertical: bool,
237}
238
239/// Which diagnostic indicators to show in the scrollbar.
240///
241/// Default: all
242#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
243#[serde(rename_all = "lowercase")]
244pub enum ScrollbarDiagnostics {
245    /// Show all diagnostic levels: hint, information, warnings, error.
246    All,
247    /// Show only the following diagnostic levels: information, warning, error.
248    Information,
249    /// Show only the following diagnostic levels: warning, error.
250    Warning,
251    /// Show only the following diagnostic level: error.
252    Error,
253    /// Do not show diagnostics.
254    None,
255}
256
257/// The key to use for adding multiple cursors
258///
259/// Default: alt
260#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
261#[serde(rename_all = "snake_case")]
262pub enum MultiCursorModifier {
263    Alt,
264    #[serde(alias = "cmd", alias = "ctrl")]
265    CmdOrCtrl,
266}
267
268/// Whether the editor will scroll beyond the last line.
269///
270/// Default: one_page
271#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
272#[serde(rename_all = "snake_case")]
273pub enum ScrollBeyondLastLine {
274    /// The editor will not scroll beyond the last line.
275    Off,
276
277    /// The editor will scroll beyond the last line by one page.
278    OnePage,
279
280    /// The editor will scroll beyond the last line by the same number of lines as vertical_scroll_margin.
281    VerticalScrollMargin,
282}
283
284/// Default options for buffer and project search items.
285#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
286pub struct SearchSettings {
287    /// Whether to show the project search button in the status bar.
288    #[serde(default = "default_true")]
289    pub button: bool,
290    #[serde(default)]
291    pub whole_word: bool,
292    #[serde(default)]
293    pub case_sensitive: bool,
294    #[serde(default)]
295    pub include_ignored: bool,
296    #[serde(default)]
297    pub regex: bool,
298}
299
300/// What to do when go to definition yields no results.
301#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
302#[serde(rename_all = "snake_case")]
303pub enum GoToDefinitionFallback {
304    /// Disables the fallback.
305    None,
306    /// Looks up references of the same symbol instead.
307    #[default]
308    FindAllReferences,
309}
310
311/// Determines when the mouse cursor should be hidden in an editor or input box.
312///
313/// Default: on_typing_and_movement
314#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
315#[serde(rename_all = "snake_case")]
316pub enum HideMouseMode {
317    /// Never hide the mouse cursor
318    Never,
319    /// Hide only when typing
320    OnTyping,
321    /// Hide on both typing and cursor movement
322    #[default]
323    OnTypingAndMovement,
324}
325
326/// Determines how snippets are sorted relative to other completion items.
327///
328/// Default: inline
329#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
330#[serde(rename_all = "snake_case")]
331pub enum SnippetSortOrder {
332    /// Place snippets at the top of the completion list
333    Top,
334    /// Sort snippets normally using the default comparison logic
335    #[default]
336    Inline,
337    /// Place snippets at the bottom of the completion list
338    Bottom,
339}
340
341#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
342#[schemars(deny_unknown_fields)]
343pub struct EditorSettingsContent {
344    /// Whether the cursor blinks in the editor.
345    ///
346    /// Default: true
347    pub cursor_blink: Option<bool>,
348    /// Cursor shape for the default editor.
349    /// Can be "bar", "block", "underline", or "hollow".
350    ///
351    /// Default: None
352    pub cursor_shape: Option<CursorShape>,
353    /// Determines when the mouse cursor should be hidden in an editor or input box.
354    ///
355    /// Default: on_typing_and_movement
356    pub hide_mouse: Option<HideMouseMode>,
357    /// Determines how snippets are sorted relative to other completion items.
358    ///
359    /// Default: inline
360    pub snippet_sort_order: Option<SnippetSortOrder>,
361    /// How to highlight the current line in the editor.
362    ///
363    /// Default: all
364    pub current_line_highlight: Option<CurrentLineHighlight>,
365    /// Whether to highlight all occurrences of the selected text in an editor.
366    ///
367    /// Default: true
368    pub selection_highlight: Option<bool>,
369    /// The debounce delay before querying highlights from the language
370    /// server based on the current cursor location.
371    ///
372    /// Default: 75
373    pub lsp_highlight_debounce: Option<u64>,
374    /// Whether to show the informational hover box when moving the mouse
375    /// over symbols in the editor.
376    ///
377    /// Default: true
378    pub hover_popover_enabled: Option<bool>,
379    /// Time to wait in milliseconds before showing the informational hover box.
380    ///
381    /// Default: 300
382    pub hover_popover_delay: Option<u64>,
383    /// Toolbar related settings
384    pub toolbar: Option<ToolbarContent>,
385    /// Scrollbar related settings
386    pub scrollbar: Option<ScrollbarContent>,
387    /// Minimap related settings
388    pub minimap: Option<MinimapContent>,
389    /// Gutter related settings
390    pub gutter: Option<GutterContent>,
391    /// Whether the editor will scroll beyond the last line.
392    ///
393    /// Default: one_page
394    pub scroll_beyond_last_line: Option<ScrollBeyondLastLine>,
395    /// The number of lines to keep above/below the cursor when auto-scrolling.
396    ///
397    /// Default: 3.
398    pub vertical_scroll_margin: Option<f32>,
399    /// Whether to scroll when clicking near the edge of the visible text area.
400    ///
401    /// Default: false
402    pub autoscroll_on_clicks: Option<bool>,
403    /// The number of characters to keep on either side when scrolling with the mouse.
404    ///
405    /// Default: 5.
406    pub horizontal_scroll_margin: Option<f32>,
407    /// Scroll sensitivity multiplier. This multiplier is applied
408    /// to both the horizontal and vertical delta values while scrolling.
409    ///
410    /// Default: 1.0
411    pub scroll_sensitivity: Option<f32>,
412    /// Scroll sensitivity multiplier for fast scrolling. This multiplier is applied
413    /// to both the horizontal and vertical delta values while scrolling. Fast scrolling
414    /// happens when a user holds the alt or option key while scrolling.
415    ///
416    /// Default: 4.0
417    pub fast_scroll_sensitivity: Option<f32>,
418    /// Whether the line numbers on editors gutter are relative or not.
419    ///
420    /// Default: false
421    pub relative_line_numbers: Option<bool>,
422    /// When to populate a new search's query based on the text under the cursor.
423    ///
424    /// Default: always
425    pub seed_search_query_from_cursor: Option<SeedQuerySetting>,
426    pub use_smartcase_search: Option<bool>,
427    /// 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.
428    ///
429    /// Default: alt
430    pub multi_cursor_modifier: Option<MultiCursorModifier>,
431    /// Hide the values of variables in `private` files, as defined by the
432    /// private_files setting. This only changes the visual representation,
433    /// the values are still present in the file and can be selected / copied / pasted
434    ///
435    /// Default: false
436    pub redact_private_values: Option<bool>,
437
438    /// How many lines to expand the multibuffer excerpts by default
439    ///
440    /// Default: 3
441    pub expand_excerpt_lines: Option<u32>,
442
443    /// Whether to enable middle-click paste on Linux
444    ///
445    /// Default: true
446    pub middle_click_paste: Option<bool>,
447
448    /// What to do when multibuffer is double clicked in some of its excerpts
449    /// (parts of singleton buffers).
450    ///
451    /// Default: select
452    pub double_click_in_multibuffer: Option<DoubleClickInMultibuffer>,
453    /// Whether the editor search results will loop
454    ///
455    /// Default: true
456    pub search_wrap: Option<bool>,
457
458    /// Defaults to use when opening a new buffer and project search items.
459    ///
460    /// Default: nothing is enabled
461    pub search: Option<SearchSettings>,
462
463    /// Whether to automatically show a signature help pop-up or not.
464    ///
465    /// Default: false
466    pub auto_signature_help: Option<bool>,
467
468    /// Whether to show the signature help pop-up after completions or bracket pairs inserted.
469    ///
470    /// Default: false
471    pub show_signature_help_after_edits: Option<bool>,
472
473    /// Whether to follow-up empty go to definition responses from the language server or not.
474    /// `FindAllReferences` allows to look up references of the same symbol instead.
475    /// `None` disables the fallback.
476    ///
477    /// Default: FindAllReferences
478    pub go_to_definition_fallback: Option<GoToDefinitionFallback>,
479
480    /// Jupyter REPL settings.
481    pub jupyter: Option<JupyterContent>,
482
483    /// Which level to use to filter out diagnostics displayed in the editor.
484    ///
485    /// Affects the editor rendering only, and does not interrupt
486    /// the functionality of diagnostics fetching and project diagnostics editor.
487    /// Which files containing diagnostic errors/warnings to mark in the tabs.
488    /// Diagnostics are only shown when file icons are also active.
489    ///
490    /// Shows all diagnostics if not specified.
491    ///
492    /// Default: warning
493    #[serde(default)]
494    pub diagnostics_max_severity: Option<DiagnosticSeverity>,
495
496    /// Whether to show code action button at start of buffer line.
497    ///
498    /// Default: true
499    pub inline_code_actions: Option<bool>,
500
501    /// Whether to allow drag and drop text selection in buffer.
502    ///
503    /// Default: true
504    pub drag_and_drop_selection: Option<bool>,
505}
506
507// Toolbar related settings
508#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
509pub struct ToolbarContent {
510    /// Whether to display breadcrumbs in the editor toolbar.
511    ///
512    /// Default: true
513    pub breadcrumbs: Option<bool>,
514    /// Whether to display quick action buttons in the editor toolbar.
515    ///
516    /// Default: true
517    pub quick_actions: Option<bool>,
518    /// Whether to show the selections menu in the editor toolbar.
519    ///
520    /// Default: true
521    pub selections_menu: Option<bool>,
522    /// Whether to display Agent review buttons in the editor toolbar.
523    /// Only applicable while reviewing a file edited by the Agent.
524    ///
525    /// Default: true
526    pub agent_review: Option<bool>,
527    /// Whether to display code action buttons in the editor toolbar.
528    ///
529    /// Default: false
530    pub code_actions: Option<bool>,
531}
532
533/// Scrollbar related settings
534#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Default)]
535pub struct ScrollbarContent {
536    /// When to show the scrollbar in the editor.
537    ///
538    /// Default: auto
539    pub show: Option<ShowScrollbar>,
540    /// Whether to show git diff indicators in the scrollbar.
541    ///
542    /// Default: true
543    pub git_diff: Option<bool>,
544    /// Whether to show buffer search result indicators in the scrollbar.
545    ///
546    /// Default: true
547    pub search_results: Option<bool>,
548    /// Whether to show selected text occurrences in the scrollbar.
549    ///
550    /// Default: true
551    pub selected_text: Option<bool>,
552    /// Whether to show selected symbol occurrences in the scrollbar.
553    ///
554    /// Default: true
555    pub selected_symbol: Option<bool>,
556    /// Which diagnostic indicators to show in the scrollbar:
557    ///
558    /// Default: all
559    pub diagnostics: Option<ScrollbarDiagnostics>,
560    /// Whether to show cursor positions in the scrollbar.
561    ///
562    /// Default: true
563    pub cursors: Option<bool>,
564    /// Forcefully enable or disable the scrollbar for each axis
565    pub axes: Option<ScrollbarAxesContent>,
566}
567
568/// Minimap related settings
569#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
570pub struct MinimapContent {
571    /// When to show the minimap in the editor.
572    ///
573    /// Default: never
574    pub show: Option<ShowMinimap>,
575
576    /// When to show the minimap thumb.
577    ///
578    /// Default: always
579    pub thumb: Option<MinimapThumb>,
580
581    /// Defines the border style for the minimap's scrollbar thumb.
582    ///
583    /// Default: left_open
584    pub thumb_border: Option<MinimapThumbBorder>,
585
586    /// How to highlight the current line in the minimap.
587    ///
588    /// Default: inherits editor line highlights setting
589    pub current_line_highlight: Option<Option<CurrentLineHighlight>>,
590}
591
592/// Forcefully enable or disable the scrollbar for each axis
593#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Default)]
594pub struct ScrollbarAxesContent {
595    /// When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings.
596    ///
597    /// Default: true
598    horizontal: Option<bool>,
599
600    /// When false, forcefully disables the vertical scrollbar. Otherwise, obey other settings.
601    ///
602    /// Default: true
603    vertical: Option<bool>,
604}
605
606/// Gutter related settings
607#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
608pub struct GutterContent {
609    /// Whether to show line numbers in the gutter.
610    ///
611    /// Default: true
612    pub line_numbers: Option<bool>,
613    /// Minimum number of characters to reserve space for in the gutter.
614    ///
615    /// Default: 4
616    pub min_line_number_digits: Option<usize>,
617    /// Whether to show runnable buttons in the gutter.
618    ///
619    /// Default: true
620    pub runnables: Option<bool>,
621    /// Whether to show breakpoints in the gutter.
622    ///
623    /// Default: true
624    pub breakpoints: Option<bool>,
625    /// Whether to show fold buttons in the gutter.
626    ///
627    /// Default: true
628    pub folds: Option<bool>,
629}
630
631impl EditorSettings {
632    pub fn jupyter_enabled(cx: &App) -> bool {
633        EditorSettings::get_global(cx).jupyter.enabled
634    }
635}
636
637impl Settings for EditorSettings {
638    const KEY: Option<&'static str> = None;
639
640    type FileContent = EditorSettingsContent;
641
642    fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> anyhow::Result<Self> {
643        sources.json_merge()
644    }
645
646    fn import_from_vscode(vscode: &VsCodeSettings, current: &mut Self::FileContent) {
647        vscode.enum_setting(
648            "editor.cursorBlinking",
649            &mut current.cursor_blink,
650            |s| match s {
651                "blink" | "phase" | "expand" | "smooth" => Some(true),
652                "solid" => Some(false),
653                _ => None,
654            },
655        );
656        vscode.enum_setting(
657            "editor.cursorStyle",
658            &mut current.cursor_shape,
659            |s| match s {
660                "block" => Some(CursorShape::Block),
661                "block-outline" => Some(CursorShape::Hollow),
662                "line" | "line-thin" => Some(CursorShape::Bar),
663                "underline" | "underline-thin" => Some(CursorShape::Underline),
664                _ => None,
665            },
666        );
667
668        vscode.enum_setting(
669            "editor.renderLineHighlight",
670            &mut current.current_line_highlight,
671            |s| match s {
672                "gutter" => Some(CurrentLineHighlight::Gutter),
673                "line" => Some(CurrentLineHighlight::Line),
674                "all" => Some(CurrentLineHighlight::All),
675                _ => None,
676            },
677        );
678
679        vscode.bool_setting(
680            "editor.selectionHighlight",
681            &mut current.selection_highlight,
682        );
683        vscode.bool_setting("editor.hover.enabled", &mut current.hover_popover_enabled);
684        vscode.u64_setting("editor.hover.delay", &mut current.hover_popover_delay);
685
686        let mut gutter = GutterContent::default();
687        vscode.enum_setting(
688            "editor.showFoldingControls",
689            &mut gutter.folds,
690            |s| match s {
691                "always" | "mouseover" => Some(true),
692                "never" => Some(false),
693                _ => None,
694            },
695        );
696        vscode.enum_setting(
697            "editor.lineNumbers",
698            &mut gutter.line_numbers,
699            |s| match s {
700                "on" | "relative" => Some(true),
701                "off" => Some(false),
702                _ => None,
703            },
704        );
705        if let Some(old_gutter) = current.gutter.as_mut() {
706            if gutter.folds.is_some() {
707                old_gutter.folds = gutter.folds
708            }
709            if gutter.line_numbers.is_some() {
710                old_gutter.line_numbers = gutter.line_numbers
711            }
712        } else {
713            if gutter != GutterContent::default() {
714                current.gutter = Some(gutter)
715            }
716        }
717        if let Some(b) = vscode.read_bool("editor.scrollBeyondLastLine") {
718            current.scroll_beyond_last_line = Some(if b {
719                ScrollBeyondLastLine::OnePage
720            } else {
721                ScrollBeyondLastLine::Off
722            })
723        }
724
725        let mut scrollbar_axes = ScrollbarAxesContent::default();
726        vscode.enum_setting(
727            "editor.scrollbar.horizontal",
728            &mut scrollbar_axes.horizontal,
729            |s| match s {
730                "auto" | "visible" => Some(true),
731                "hidden" => Some(false),
732                _ => None,
733            },
734        );
735        vscode.enum_setting(
736            "editor.scrollbar.vertical",
737            &mut scrollbar_axes.horizontal,
738            |s| match s {
739                "auto" | "visible" => Some(true),
740                "hidden" => Some(false),
741                _ => None,
742            },
743        );
744
745        if scrollbar_axes != ScrollbarAxesContent::default() {
746            let scrollbar_settings = current.scrollbar.get_or_insert_default();
747            let axes_settings = scrollbar_settings.axes.get_or_insert_default();
748
749            if let Some(vertical) = scrollbar_axes.vertical {
750                axes_settings.vertical = Some(vertical);
751            }
752            if let Some(horizontal) = scrollbar_axes.horizontal {
753                axes_settings.horizontal = Some(horizontal);
754            }
755        }
756
757        // TODO: check if this does the int->float conversion?
758        vscode.f32_setting(
759            "editor.cursorSurroundingLines",
760            &mut current.vertical_scroll_margin,
761        );
762        vscode.f32_setting(
763            "editor.mouseWheelScrollSensitivity",
764            &mut current.scroll_sensitivity,
765        );
766        vscode.f32_setting(
767            "editor.fastScrollSensitivity",
768            &mut current.fast_scroll_sensitivity,
769        );
770        if Some("relative") == vscode.read_string("editor.lineNumbers") {
771            current.relative_line_numbers = Some(true);
772        }
773
774        vscode.enum_setting(
775            "editor.find.seedSearchStringFromSelection",
776            &mut current.seed_search_query_from_cursor,
777            |s| match s {
778                "always" => Some(SeedQuerySetting::Always),
779                "selection" => Some(SeedQuerySetting::Selection),
780                "never" => Some(SeedQuerySetting::Never),
781                _ => None,
782            },
783        );
784        vscode.bool_setting("search.smartCase", &mut current.use_smartcase_search);
785        vscode.enum_setting(
786            "editor.multiCursorModifier",
787            &mut current.multi_cursor_modifier,
788            |s| match s {
789                "ctrlCmd" => Some(MultiCursorModifier::CmdOrCtrl),
790                "alt" => Some(MultiCursorModifier::Alt),
791                _ => None,
792            },
793        );
794
795        vscode.bool_setting(
796            "editor.parameterHints.enabled",
797            &mut current.auto_signature_help,
798        );
799        vscode.bool_setting(
800            "editor.parameterHints.enabled",
801            &mut current.show_signature_help_after_edits,
802        );
803
804        if let Some(use_ignored) = vscode.read_bool("search.useIgnoreFiles") {
805            let search = current.search.get_or_insert_default();
806            search.include_ignored = use_ignored;
807        }
808
809        let mut minimap = MinimapContent::default();
810        let minimap_enabled = vscode.read_bool("editor.minimap.enabled").unwrap_or(true);
811        let autohide = vscode.read_bool("editor.minimap.autohide");
812        if minimap_enabled {
813            if let Some(false) = autohide {
814                minimap.show = Some(ShowMinimap::Always);
815            } else {
816                minimap.show = Some(ShowMinimap::Auto);
817            }
818        } else {
819            minimap.show = Some(ShowMinimap::Never);
820        }
821
822        vscode.enum_setting(
823            "editor.minimap.showSlider",
824            &mut minimap.thumb,
825            |s| match s {
826                "always" => Some(MinimapThumb::Always),
827                "mouseover" => Some(MinimapThumb::Hover),
828                _ => None,
829            },
830        );
831
832        if minimap != MinimapContent::default() {
833            current.minimap = Some(minimap)
834        }
835    }
836}