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