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