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