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