1use std::num;
2
3use collections::HashMap;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use serde_with::skip_serializing_none;
7use settings_macros::MergeFrom;
8
9use crate::{DiagnosticSeverityContent, ShowScrollbar};
10
11#[skip_serializing_none]
12#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
13pub struct EditorSettingsContent {
14 /// Whether the cursor blinks in the editor.
15 ///
16 /// Default: true
17 pub cursor_blink: Option<bool>,
18 /// Cursor shape for the default editor.
19 /// Can be "bar", "block", "underline", or "hollow".
20 ///
21 /// Default: bar
22 pub cursor_shape: Option<CursorShape>,
23 /// Determines when the mouse cursor should be hidden in an editor or input box.
24 ///
25 /// Default: on_typing_and_movement
26 pub hide_mouse: Option<HideMouseMode>,
27 /// Determines how snippets are sorted relative to other completion items.
28 ///
29 /// Default: inline
30 pub snippet_sort_order: Option<SnippetSortOrder>,
31 /// How to highlight the current line in the editor.
32 ///
33 /// Default: all
34 pub current_line_highlight: Option<CurrentLineHighlight>,
35 /// Whether to highlight all occurrences of the selected text in an editor.
36 ///
37 /// Default: true
38 pub selection_highlight: Option<bool>,
39 /// Whether the text selection should have rounded corners.
40 ///
41 /// Default: true
42 pub rounded_selection: Option<bool>,
43 /// The debounce delay before querying highlights from the language
44 /// server based on the current cursor location.
45 ///
46 /// Default: 75
47 pub lsp_highlight_debounce: Option<u64>,
48 /// Whether to show the informational hover box when moving the mouse
49 /// over symbols in the editor.
50 ///
51 /// Default: true
52 pub hover_popover_enabled: Option<bool>,
53 /// Time to wait in milliseconds before showing the informational hover box.
54 ///
55 /// Default: 300
56 pub hover_popover_delay: Option<u64>,
57 /// Toolbar related settings
58 pub toolbar: Option<ToolbarContent>,
59 /// Scrollbar related settings
60 pub scrollbar: Option<ScrollbarContent>,
61 /// Minimap related settings
62 pub minimap: Option<MinimapContent>,
63 /// Gutter related settings
64 pub gutter: Option<GutterContent>,
65 /// Whether the editor will scroll beyond the last line.
66 ///
67 /// Default: one_page
68 pub scroll_beyond_last_line: Option<ScrollBeyondLastLine>,
69 /// The number of lines to keep above/below the cursor when auto-scrolling.
70 ///
71 /// Default: 3.
72 pub vertical_scroll_margin: Option<f32>,
73 /// Whether to scroll when clicking near the edge of the visible text area.
74 ///
75 /// Default: false
76 pub autoscroll_on_clicks: Option<bool>,
77 /// The number of characters to keep on either side when scrolling with the mouse.
78 ///
79 /// Default: 5.
80 pub horizontal_scroll_margin: Option<f32>,
81 /// Scroll sensitivity multiplier. This multiplier is applied
82 /// to both the horizontal and vertical delta values while scrolling.
83 ///
84 /// Default: 1.0
85 pub scroll_sensitivity: Option<f32>,
86 /// Scroll sensitivity multiplier for fast scrolling. This multiplier is applied
87 /// to both the horizontal and vertical delta values while scrolling. Fast scrolling
88 /// happens when a user holds the alt or option key while scrolling.
89 ///
90 /// Default: 4.0
91 pub fast_scroll_sensitivity: Option<f32>,
92 /// Whether the line numbers on editors gutter are relative or not.
93 ///
94 /// Default: false
95 pub relative_line_numbers: Option<bool>,
96 /// When to populate a new search's query based on the text under the cursor.
97 ///
98 /// Default: always
99 pub seed_search_query_from_cursor: Option<SeedQuerySetting>,
100 pub use_smartcase_search: Option<bool>,
101 /// 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.
102 ///
103 /// Default: alt
104 pub multi_cursor_modifier: Option<MultiCursorModifier>,
105 /// Hide the values of variables in `private` files, as defined by the
106 /// private_files setting. This only changes the visual representation,
107 /// the values are still present in the file and can be selected / copied / pasted
108 ///
109 /// Default: false
110 pub redact_private_values: Option<bool>,
111
112 /// How many lines to expand the multibuffer excerpts by default
113 ///
114 /// Default: 3
115 pub expand_excerpt_lines: Option<u32>,
116
117 /// How many lines of context to provide in multibuffer excerpts by default
118 ///
119 /// Default: 2
120 pub excerpt_context_lines: Option<u32>,
121
122 /// Whether to enable middle-click paste on Linux
123 ///
124 /// Default: true
125 pub middle_click_paste: Option<bool>,
126
127 /// What to do when multibuffer is double clicked in some of its excerpts
128 /// (parts of singleton buffers).
129 ///
130 /// Default: select
131 pub double_click_in_multibuffer: Option<DoubleClickInMultibuffer>,
132 /// Whether the editor search results will loop
133 ///
134 /// Default: true
135 pub search_wrap: Option<bool>,
136
137 /// Defaults to use when opening a new buffer and project search items.
138 ///
139 /// Default: nothing is enabled
140 pub search: Option<SearchSettingsContent>,
141
142 /// Whether to automatically show a signature help pop-up or not.
143 ///
144 /// Default: false
145 pub auto_signature_help: Option<bool>,
146
147 /// Whether to show the signature help pop-up after completions or bracket pairs inserted.
148 ///
149 /// Default: false
150 pub show_signature_help_after_edits: Option<bool>,
151 /// The minimum APCA perceptual contrast to maintain when
152 /// rendering text over highlight backgrounds in the editor.
153 ///
154 /// Values range from 0 to 106. Set to 0 to disable adjustments.
155 /// Default: 45
156 pub minimum_contrast_for_highlights: Option<f32>,
157
158 /// Whether to follow-up empty go to definition responses from the language server or not.
159 /// `FindAllReferences` allows to look up references of the same symbol instead.
160 /// `None` disables the fallback.
161 ///
162 /// Default: FindAllReferences
163 pub go_to_definition_fallback: Option<GoToDefinitionFallback>,
164
165 /// Jupyter REPL settings.
166 pub jupyter: Option<JupyterContent>,
167
168 /// Which level to use to filter out diagnostics displayed in the editor.
169 ///
170 /// Affects the editor rendering only, and does not interrupt
171 /// the functionality of diagnostics fetching and project diagnostics editor.
172 /// Which files containing diagnostic errors/warnings to mark in the tabs.
173 /// Diagnostics are only shown when file icons are also active.
174 ///
175 /// Shows all diagnostics if not specified.
176 ///
177 /// Default: warning
178 pub diagnostics_max_severity: Option<DiagnosticSeverityContent>,
179
180 /// Whether to show code action button at start of buffer line.
181 ///
182 /// Default: true
183 pub inline_code_actions: Option<bool>,
184
185 /// Drag and drop related settings
186 pub drag_and_drop_selection: Option<DragAndDropSelectionContent>,
187
188 /// How to render LSP `textDocument/documentColor` colors in the editor.
189 ///
190 /// Default: [`DocumentColorsRenderMode::Inlay`]
191 pub lsp_document_colors: Option<DocumentColorsRenderMode>,
192}
193
194// Toolbar related settings
195#[skip_serializing_none]
196#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
197pub struct ToolbarContent {
198 /// Whether to display breadcrumbs in the editor toolbar.
199 ///
200 /// Default: true
201 pub breadcrumbs: Option<bool>,
202 /// Whether to display quick action buttons in the editor toolbar.
203 ///
204 /// Default: true
205 pub quick_actions: Option<bool>,
206 /// Whether to show the selections menu in the editor toolbar.
207 ///
208 /// Default: true
209 pub selections_menu: Option<bool>,
210 /// Whether to display Agent review buttons in the editor toolbar.
211 /// Only applicable while reviewing a file edited by the Agent.
212 ///
213 /// Default: true
214 pub agent_review: Option<bool>,
215 /// Whether to display code action buttons in the editor toolbar.
216 ///
217 /// Default: false
218 pub code_actions: Option<bool>,
219}
220
221/// Scrollbar related settings
222#[skip_serializing_none]
223#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
224pub struct ScrollbarContent {
225 /// When to show the scrollbar in the editor.
226 ///
227 /// Default: auto
228 pub show: Option<ShowScrollbar>,
229 /// Whether to show git diff indicators in the scrollbar.
230 ///
231 /// Default: true
232 pub git_diff: Option<bool>,
233 /// Whether to show buffer search result indicators in the scrollbar.
234 ///
235 /// Default: true
236 pub search_results: Option<bool>,
237 /// Whether to show selected text occurrences in the scrollbar.
238 ///
239 /// Default: true
240 pub selected_text: Option<bool>,
241 /// Whether to show selected symbol occurrences in the scrollbar.
242 ///
243 /// Default: true
244 pub selected_symbol: Option<bool>,
245 /// Which diagnostic indicators to show in the scrollbar:
246 ///
247 /// Default: all
248 pub diagnostics: Option<ScrollbarDiagnostics>,
249 /// Whether to show cursor positions in the scrollbar.
250 ///
251 /// Default: true
252 pub cursors: Option<bool>,
253 /// Forcefully enable or disable the scrollbar for each axis
254 pub axes: Option<ScrollbarAxesContent>,
255}
256
257/// Minimap related settings
258#[skip_serializing_none]
259#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
260pub struct MinimapContent {
261 /// When to show the minimap in the editor.
262 ///
263 /// Default: never
264 pub show: Option<ShowMinimap>,
265
266 /// Where to show the minimap in the editor.
267 ///
268 /// Default: [`DisplayIn::ActiveEditor`]
269 pub display_in: Option<DisplayIn>,
270
271 /// When to show the minimap thumb.
272 ///
273 /// Default: always
274 pub thumb: Option<MinimapThumb>,
275
276 /// Defines the border style for the minimap's scrollbar thumb.
277 ///
278 /// Default: left_open
279 pub thumb_border: Option<MinimapThumbBorder>,
280
281 /// How to highlight the current line in the minimap.
282 ///
283 /// Default: inherits editor line highlights setting
284 pub current_line_highlight: Option<CurrentLineHighlight>,
285
286 /// Maximum number of columns to display in the minimap.
287 ///
288 /// Default: 80
289 pub max_width_columns: Option<num::NonZeroU32>,
290}
291
292/// Forcefully enable or disable the scrollbar for each axis
293#[skip_serializing_none]
294#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
295pub struct ScrollbarAxesContent {
296 /// When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings.
297 ///
298 /// Default: true
299 pub horizontal: Option<bool>,
300
301 /// When false, forcefully disables the vertical scrollbar. Otherwise, obey other settings.
302 ///
303 /// Default: true
304 pub vertical: Option<bool>,
305}
306
307/// Gutter related settings
308#[skip_serializing_none]
309#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
310pub struct GutterContent {
311 /// Whether to show line numbers in the gutter.
312 ///
313 /// Default: true
314 pub line_numbers: Option<bool>,
315 /// Minimum number of characters to reserve space for in the gutter.
316 ///
317 /// Default: 4
318 pub min_line_number_digits: Option<usize>,
319 /// Whether to show runnable buttons in the gutter.
320 ///
321 /// Default: true
322 pub runnables: Option<bool>,
323 /// Whether to show breakpoints in the gutter.
324 ///
325 /// Default: true
326 pub breakpoints: Option<bool>,
327 /// Whether to show fold buttons in the gutter.
328 ///
329 /// Default: true
330 pub folds: Option<bool>,
331}
332
333/// How to render LSP `textDocument/documentColor` colors in the editor.
334#[derive(
335 Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom,
336)]
337#[serde(rename_all = "snake_case")]
338pub enum DocumentColorsRenderMode {
339 /// Do not query and render document colors.
340 None,
341 /// Render document colors as inlay hints near the color text.
342 #[default]
343 Inlay,
344 /// Draw a border around the color text.
345 Border,
346 /// Draw a background behind the color text.
347 Background,
348}
349
350#[derive(
351 Copy,
352 Clone,
353 Debug,
354 Serialize,
355 Deserialize,
356 PartialEq,
357 Eq,
358 JsonSchema,
359 MergeFrom,
360 strum::VariantArray,
361 strum::VariantNames,
362)]
363#[serde(rename_all = "snake_case")]
364pub enum CurrentLineHighlight {
365 // Don't highlight the current line.
366 None,
367 // Highlight the gutter area.
368 Gutter,
369 // Highlight the editor area.
370 Line,
371 // Highlight the full line.
372 All,
373}
374
375/// When to populate a new search's query based on the text under the cursor.
376#[derive(
377 Copy,
378 Clone,
379 Debug,
380 Serialize,
381 Deserialize,
382 PartialEq,
383 Eq,
384 JsonSchema,
385 MergeFrom,
386 strum::VariantArray,
387 strum::VariantNames,
388)]
389#[serde(rename_all = "snake_case")]
390pub enum SeedQuerySetting {
391 /// Always populate the search query with the word under the cursor.
392 Always,
393 /// Only populate the search query when there is text selected.
394 Selection,
395 /// Never populate the search query
396 Never,
397}
398
399/// What to do when multibuffer is double clicked in some of its excerpts (parts of singleton buffers).
400#[derive(
401 Default,
402 Copy,
403 Clone,
404 Debug,
405 Serialize,
406 Deserialize,
407 PartialEq,
408 Eq,
409 JsonSchema,
410 MergeFrom,
411 strum::VariantArray,
412 strum::VariantNames,
413)]
414#[serde(rename_all = "snake_case")]
415pub enum DoubleClickInMultibuffer {
416 /// Behave as a regular buffer and select the whole word.
417 #[default]
418 Select,
419 /// Open the excerpt clicked as a new buffer in the new tab, if no `alt` modifier was pressed during double click.
420 /// Otherwise, behave as a regular buffer and select the whole word.
421 Open,
422}
423
424/// When to show the minimap thumb.
425///
426/// Default: always
427#[derive(
428 Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
429)]
430#[serde(rename_all = "snake_case")]
431pub enum MinimapThumb {
432 /// Show the minimap thumb only when the mouse is hovering over the minimap.
433 Hover,
434 /// Always show the minimap thumb.
435 #[default]
436 Always,
437}
438
439/// Defines the border style for the minimap's scrollbar thumb.
440///
441/// Default: left_open
442#[derive(
443 Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
444)]
445#[serde(rename_all = "snake_case")]
446pub enum MinimapThumbBorder {
447 /// Displays a border on all sides of the thumb.
448 Full,
449 /// Displays a border on all sides except the left side of the thumb.
450 #[default]
451 LeftOpen,
452 /// Displays a border on all sides except the right side of the thumb.
453 RightOpen,
454 /// Displays a border only on the left side of the thumb.
455 LeftOnly,
456 /// Displays the thumb without any border.
457 None,
458}
459
460/// Which diagnostic indicators to show in the scrollbar.
461///
462/// Default: all
463#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
464#[serde(rename_all = "lowercase")]
465pub enum ScrollbarDiagnostics {
466 /// Show all diagnostic levels: hint, information, warnings, error.
467 All,
468 /// Show only the following diagnostic levels: information, warning, error.
469 Information,
470 /// Show only the following diagnostic levels: warning, error.
471 Warning,
472 /// Show only the following diagnostic level: error.
473 Error,
474 /// Do not show diagnostics.
475 None,
476}
477
478/// The key to use for adding multiple cursors
479///
480/// Default: alt
481#[derive(
482 Copy,
483 Clone,
484 Debug,
485 Serialize,
486 Deserialize,
487 JsonSchema,
488 MergeFrom,
489 PartialEq,
490 Eq,
491 strum::VariantArray,
492 strum::VariantNames,
493)]
494#[serde(rename_all = "snake_case")]
495pub enum MultiCursorModifier {
496 Alt,
497 #[serde(alias = "cmd", alias = "ctrl")]
498 CmdOrCtrl,
499}
500
501/// Whether the editor will scroll beyond the last line.
502///
503/// Default: one_page
504#[derive(
505 Copy,
506 Clone,
507 Debug,
508 Serialize,
509 Deserialize,
510 JsonSchema,
511 MergeFrom,
512 PartialEq,
513 Eq,
514 strum::VariantArray,
515 strum::VariantNames,
516)]
517#[serde(rename_all = "snake_case")]
518pub enum ScrollBeyondLastLine {
519 /// The editor will not scroll beyond the last line.
520 Off,
521
522 /// The editor will scroll beyond the last line by one page.
523 OnePage,
524
525 /// The editor will scroll beyond the last line by the same number of lines as vertical_scroll_margin.
526 VerticalScrollMargin,
527}
528
529/// The shape of a selection cursor.
530#[derive(
531 Copy,
532 Clone,
533 Debug,
534 Default,
535 Serialize,
536 Deserialize,
537 PartialEq,
538 Eq,
539 JsonSchema,
540 MergeFrom,
541 strum::VariantArray,
542 strum::VariantNames,
543)]
544#[serde(rename_all = "snake_case")]
545pub enum CursorShape {
546 /// A vertical bar
547 #[default]
548 Bar,
549 /// A block that surrounds the following character
550 Block,
551 /// An underline that runs along the following character
552 Underline,
553 /// A box drawn around the following character
554 Hollow,
555}
556
557/// What to do when go to definition yields no results.
558#[derive(
559 Copy,
560 Clone,
561 Debug,
562 Default,
563 Serialize,
564 Deserialize,
565 PartialEq,
566 Eq,
567 JsonSchema,
568 MergeFrom,
569 strum::VariantArray,
570 strum::VariantNames,
571)]
572#[serde(rename_all = "snake_case")]
573pub enum GoToDefinitionFallback {
574 /// Disables the fallback.
575 None,
576 /// Looks up references of the same symbol instead.
577 #[default]
578 FindAllReferences,
579}
580
581/// Determines when the mouse cursor should be hidden in an editor or input box.
582///
583/// Default: on_typing_and_movement
584#[derive(
585 Copy,
586 Clone,
587 Debug,
588 Default,
589 Serialize,
590 Deserialize,
591 PartialEq,
592 Eq,
593 JsonSchema,
594 MergeFrom,
595 strum::VariantArray,
596 strum::VariantNames,
597)]
598#[serde(rename_all = "snake_case")]
599pub enum HideMouseMode {
600 /// Never hide the mouse cursor
601 Never,
602 /// Hide only when typing
603 OnTyping,
604 /// Hide on both typing and cursor movement
605 #[default]
606 OnTypingAndMovement,
607}
608
609/// Determines how snippets are sorted relative to other completion items.
610///
611/// Default: inline
612#[derive(
613 Copy,
614 Clone,
615 Debug,
616 Default,
617 Serialize,
618 Deserialize,
619 PartialEq,
620 Eq,
621 JsonSchema,
622 MergeFrom,
623 strum::VariantArray,
624 strum::VariantNames,
625)]
626#[serde(rename_all = "snake_case")]
627pub enum SnippetSortOrder {
628 /// Place snippets at the top of the completion list
629 Top,
630 /// Sort snippets normally using the default comparison logic
631 #[default]
632 Inline,
633 /// Place snippets at the bottom of the completion list
634 Bottom,
635 /// Do not show snippets in the completion list
636 None,
637}
638
639/// Default options for buffer and project search items.
640#[skip_serializing_none]
641#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
642pub struct SearchSettingsContent {
643 /// Whether to show the project search button in the status bar.
644 pub button: Option<bool>,
645 pub whole_word: Option<bool>,
646 pub case_sensitive: Option<bool>,
647 pub include_ignored: Option<bool>,
648 pub regex: Option<bool>,
649}
650
651#[skip_serializing_none]
652#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
653#[serde(rename_all = "snake_case")]
654pub struct JupyterContent {
655 /// Whether the Jupyter feature is enabled.
656 ///
657 /// Default: true
658 pub enabled: Option<bool>,
659
660 /// Default kernels to select for each language.
661 ///
662 /// Default: `{}`
663 pub kernel_selections: Option<HashMap<String, String>>,
664}
665
666/// Whether to allow drag and drop text selection in buffer.
667#[skip_serializing_none]
668#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
669pub struct DragAndDropSelectionContent {
670 /// When true, enables drag and drop text selection in buffer.
671 ///
672 /// Default: true
673 pub enabled: Option<bool>,
674
675 /// The delay in milliseconds that must elapse before drag and drop is allowed. Otherwise, a new text selection is created.
676 ///
677 /// Default: 300
678 pub delay: Option<u64>,
679}
680
681/// When to show the minimap in the editor.
682///
683/// Default: never
684#[derive(
685 Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
686)]
687#[serde(rename_all = "snake_case")]
688pub enum ShowMinimap {
689 /// Follow the visibility of the scrollbar.
690 Auto,
691 /// Always show the minimap.
692 Always,
693 /// Never show the minimap.
694 #[default]
695 Never,
696}
697
698/// Where to show the minimap in the editor.
699///
700/// Default: all_editors
701#[derive(
702 Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
703)]
704#[serde(rename_all = "snake_case")]
705pub enum DisplayIn {
706 /// Show on all open editors.
707 AllEditors,
708 /// Show the minimap on the active editor only.
709 #[default]
710 ActiveEditor,
711}