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