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