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