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