The current gutter was a bit too big for my taste, so I added some settings to change which visual elements are shown, including being able to hide the gutter completely. This should help with the following issues: #4963, #4382, #7422 New settings: ```json5 "gutter": { "line_numbers": true, // Whether line numbers are shown "buttons": true // Whether the code action/folding buttons are shown } ``` The existing `git.git_gutter` setting is also taken into account when calculating the width of the gutter. We could also separate the display of the code action and folding buttons into separate settings, let me know if that is desirable. ## Screenshots: - Everything on (`gutter.line_numbers`, `gutter.buttons`, `git.git_gutter`): <img width="434" alt="SCR-20240210-trfb" src="https://github.com/zed-industries/zed/assets/17355488/bcc55311-6e1d-4c22-8c43-4f364637959b"> - Only line numbers and git gutter (`gutter.line_numbers`, `git.git_gutter`): <img width="406" alt="SCR-20240210-trhm" src="https://github.com/zed-industries/zed/assets/17355488/0a0e074d-64d0-437c-851b-55560d5a6c6b"> - Only git gutter (`git.git_gutter`): <img width="356" alt="SCR-20240210-trkb" src="https://github.com/zed-industries/zed/assets/17355488/7ebdb38d-93a5-4e38-b008-beabf355510d"> - Only git gutter and buttons (`git.git_gutter`, `gutter.buttons`): <img width="356" alt="SCR-20240210-txyo" src="https://github.com/zed-industries/zed/assets/17355488/e2c92c05-cc30-43bc-9399-09ea5e376e1b"> - Nothing: <img width="350" alt="SCR-20240210-trne" src="https://github.com/zed-industries/zed/assets/17355488/e0cd301d-c3e0-4b31-ac69-997515928b5a"> ## Release Notes: - Added settings to control the display of gutter visual elements. `"gutter": {"line_numbers": true, "code_actions": true, "folds": true}` ([#8041](https://github.com/zed-industries/zed/issues/8041)) ([#7422](https://github.com/zed-industries/zed/issues/7422)) ``` --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
200 lines
6.3 KiB
Rust
200 lines
6.3 KiB
Rust
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
use settings::Settings;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct EditorSettings {
|
|
pub cursor_blink: bool,
|
|
pub hover_popover_enabled: bool,
|
|
pub show_completions_on_input: bool,
|
|
pub show_completion_documentation: bool,
|
|
pub completion_documentation_secondary_query_debounce: u64,
|
|
pub use_on_type_format: bool,
|
|
pub toolbar: Toolbar,
|
|
pub scrollbar: Scrollbar,
|
|
pub gutter: Gutter,
|
|
pub vertical_scroll_margin: f32,
|
|
pub relative_line_numbers: bool,
|
|
pub seed_search_query_from_cursor: SeedQuerySetting,
|
|
pub redact_private_values: bool,
|
|
}
|
|
|
|
/// When to populate a new search's query based on the text under the cursor.
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum SeedQuerySetting {
|
|
/// Always populate the search query with the word under the cursor.
|
|
Always,
|
|
/// Only populate the search query when there is text selected.
|
|
Selection,
|
|
/// Never populate the search query
|
|
Never,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
|
pub struct Toolbar {
|
|
pub breadcrumbs: bool,
|
|
pub quick_actions: bool,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
|
pub struct Scrollbar {
|
|
pub show: ShowScrollbar,
|
|
pub git_diff: bool,
|
|
pub selections: bool,
|
|
pub symbols_selections: bool,
|
|
pub diagnostics: bool,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
|
pub struct Gutter {
|
|
pub line_numbers: bool,
|
|
pub code_actions: bool,
|
|
pub folds: bool,
|
|
}
|
|
|
|
/// When to show the scrollbar in the editor.
|
|
///
|
|
/// Default: auto
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ShowScrollbar {
|
|
/// Show the scrollbar if there's important information or
|
|
/// follow the system's configured behavior.
|
|
Auto,
|
|
/// Match the system's configured behavior.
|
|
System,
|
|
/// Always show the scrollbar.
|
|
Always,
|
|
/// Never show the scrollbar.
|
|
Never,
|
|
}
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
|
pub struct EditorSettingsContent {
|
|
/// Whether the cursor blinks in the editor.
|
|
///
|
|
/// Default: true
|
|
pub cursor_blink: Option<bool>,
|
|
/// Whether to show the informational hover box when moving the mouse
|
|
/// over symbols in the editor.
|
|
///
|
|
/// Default: true
|
|
pub hover_popover_enabled: Option<bool>,
|
|
/// Whether to pop the completions menu while typing in an editor without
|
|
/// explicitly requesting it.
|
|
///
|
|
/// Default: true
|
|
pub show_completions_on_input: Option<bool>,
|
|
/// Whether to display inline and alongside documentation for items in the
|
|
/// completions menu.
|
|
///
|
|
/// Default: true
|
|
pub show_completion_documentation: Option<bool>,
|
|
/// The debounce delay before re-querying the language server for completion
|
|
/// documentation when not included in original completion list.
|
|
///
|
|
/// Default: 300 ms
|
|
pub completion_documentation_secondary_query_debounce: Option<u64>,
|
|
/// Whether to use additional LSP queries to format (and amend) the code after
|
|
/// every "trigger" symbol input, defined by LSP server capabilities.
|
|
///
|
|
/// Default: true
|
|
pub use_on_type_format: Option<bool>,
|
|
/// Toolbar related settings
|
|
pub toolbar: Option<ToolbarContent>,
|
|
/// Scrollbar related settings
|
|
pub scrollbar: Option<ScrollbarContent>,
|
|
/// Gutter related settings
|
|
pub gutter: Option<GutterContent>,
|
|
|
|
/// The number of lines to keep above/below the cursor when auto-scrolling.
|
|
///
|
|
/// Default: 3.
|
|
pub vertical_scroll_margin: Option<f32>,
|
|
/// Whether the line numbers on editors gutter are relative or not.
|
|
///
|
|
/// Default: false
|
|
pub relative_line_numbers: Option<bool>,
|
|
/// When to populate a new search's query based on the text under the cursor.
|
|
///
|
|
/// Default: always
|
|
pub seed_search_query_from_cursor: Option<SeedQuerySetting>,
|
|
|
|
/// Hide the values of variables in `private` files, as defined by the
|
|
/// private_files setting. This only changes the visual representation,
|
|
/// the values are still present in the file and can be selected / copied / pasted
|
|
///
|
|
/// Default: false
|
|
pub redact_private_values: Option<bool>,
|
|
}
|
|
|
|
// Toolbar related settings
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
|
pub struct ToolbarContent {
|
|
/// Whether to display breadcrumbs in the editor toolbar.
|
|
///
|
|
/// Default: true
|
|
pub breadcrumbs: Option<bool>,
|
|
/// Whether to display quik action buttons in the editor toolbar.
|
|
///
|
|
/// Default: true
|
|
pub quick_actions: Option<bool>,
|
|
}
|
|
|
|
/// Scrollbar related settings
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
|
pub struct ScrollbarContent {
|
|
/// When to show the scrollbar in the editor.
|
|
///
|
|
/// Default: auto
|
|
pub show: Option<ShowScrollbar>,
|
|
/// Whether to show git diff indicators in the scrollbar.
|
|
///
|
|
/// Default: true
|
|
pub git_diff: Option<bool>,
|
|
/// Whether to show buffer search result markers in the scrollbar.
|
|
///
|
|
/// Default: true
|
|
pub selections: Option<bool>,
|
|
/// Whether to show symbols highlighted markers in the scrollbar.
|
|
///
|
|
/// Default: true
|
|
pub symbols_selections: Option<bool>,
|
|
/// Whether to show diagnostic indicators in the scrollbar.
|
|
///
|
|
/// Default: true
|
|
pub diagnostics: Option<bool>,
|
|
}
|
|
|
|
/// Gutter related settings
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
|
pub struct GutterContent {
|
|
/// Whether to show line numbers in the gutter.
|
|
///
|
|
/// Default: true
|
|
pub line_numbers: Option<bool>,
|
|
/// Whether to show code action buttons in the gutter.
|
|
///
|
|
/// Default: true
|
|
pub code_actions: Option<bool>,
|
|
/// Whether to show fold buttons in the gutter.
|
|
///
|
|
/// Default: true
|
|
pub folds: Option<bool>,
|
|
}
|
|
|
|
impl Settings for EditorSettings {
|
|
const KEY: Option<&'static str> = None;
|
|
|
|
type FileContent = EditorSettingsContent;
|
|
|
|
fn load(
|
|
default_value: &Self::FileContent,
|
|
user_values: &[&Self::FileContent],
|
|
_: &mut gpui::AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
Self::load_via_json_merge(default_value, user_values)
|
|
}
|
|
}
|