998 lines · 28.6 KB · Rust
RawDownload
use std::num::NonZeroUsize; use collections::HashMap;use schemars::JsonSchema;use serde::{Deserialize, Serialize};use settings_macros::{MergeFrom, with_fallible_options}; use crate::{    CenteredPaddingSettings, DelayMs, DockPosition, DockSide, InactiveOpacity, ShowIndentGuides,    ShowScrollbar, serialize_optional_f32_with_two_decimal_places,}; #[with_fallible_options]#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]pub struct WorkspaceSettingsContent {    /// Active pane styling settings.    pub active_pane_modifiers: Option<ActivePaneModifiers>,    /// The text rendering mode to use.    ///    /// Default: platform_default    pub text_rendering_mode: Option<TextRenderingMode>,    /// Layout mode for the bottom dock    ///    /// Default: contained    pub bottom_dock_layout: Option<BottomDockLayout>,    /// Direction to split horizontally.    ///    /// Default: "up"    pub pane_split_direction_horizontal: Option<PaneSplitDirectionHorizontal>,    /// Direction to split vertically.    ///    /// Default: "left"    pub pane_split_direction_vertical: Option<PaneSplitDirectionVertical>,    /// Centered layout related settings.    pub centered_layout: Option<CenteredLayoutSettings>,    /// Whether or not to prompt the user to confirm before closing the application.    ///    /// Default: false    pub confirm_quit: Option<bool>,    /// Whether or not to show the call status icon in the status bar.    ///    /// Default: true    pub show_call_status_icon: Option<bool>,    /// When to automatically save edited buffers.    ///    /// Default: off    pub autosave: Option<AutosaveSetting>,    /// Controls previous session restoration in freshly launched Zed instance.    /// Values: empty_tab, last_workspace, last_session, launchpad    /// Default: last_session    pub restore_on_startup: Option<RestoreOnStartupBehavior>,    /// Whether to attempt to restore previous file's state when opening it again.    /// The state is stored per pane.    /// When disabled, defaults are applied instead of the state restoration.    ///    /// E.g. for editors, selections, folds and scroll positions are restored, if the same file is closed and, later, opened again in the same pane.    /// When disabled, a single selection in the very beginning of the file, zero scroll position and no folds state is used as a default.    ///    /// Default: true    pub restore_on_file_reopen: Option<bool>,    /// The size of the workspace split drop targets on the outer edges.    /// Given as a fraction that will be multiplied by the smaller dimension of the workspace.    ///    /// Default: `0.2` (20% of the smaller dimension of the workspace)    #[serde(serialize_with = "serialize_optional_f32_with_two_decimal_places")]    pub drop_target_size: Option<f32>,    /// Whether to close the window when using 'close active item' on a workspace with no tabs    ///    /// Default: auto ("on" on macOS, "off" otherwise)    pub when_closing_with_no_tabs: Option<CloseWindowWhenNoItems>,    /// Whether to use the system provided dialogs for Open and Save As.    /// When set to false, Zed will use the built-in keyboard-first pickers.    ///    /// Default: true    pub use_system_path_prompts: Option<bool>,    /// Whether to use the system provided prompts.    /// When set to false, Zed will use the built-in prompts.    /// Note that this setting has no effect on Linux, where Zed will always    /// use the built-in prompts.    ///    /// Default: true    pub use_system_prompts: Option<bool>,    /// Aliases for the command palette. When you type a key in this map,    /// it will be assumed to equal the value.    ///    /// Default: true    #[serde(default)]    pub command_aliases: HashMap<String, String>,    /// Maximum open tabs in a pane. Will not close an unsaved    /// tab. Set to `None` for unlimited tabs.    ///    /// Default: none    pub max_tabs: Option<NonZeroUsize>,    /// What to do when the last window is closed    ///    /// Default: auto (nothing on macOS, "app quit" otherwise)    pub on_last_window_closed: Option<OnLastWindowClosed>,    /// Whether to resize all the panels in a dock when resizing the dock.    ///    /// Default: ["left"]    pub resize_all_panels_in_dock: Option<Vec<DockPosition>>,    /// Whether to automatically close files that have been deleted on disk.    ///    /// Default: false    pub close_on_file_delete: Option<bool>,    /// Whether to allow windows to tab together based on the user’s tabbing preference (macOS only).    ///    /// Default: false    pub use_system_window_tabs: Option<bool>,    /// Whether to show padding for zoomed panels.    /// When enabled, zoomed bottom panels will have some top padding,    /// while zoomed left/right panels will have padding to the right/left (respectively).    ///    /// Default: true    pub zoomed_padding: Option<bool>,    /// Whether toggling a panel (e.g. with its keyboard shortcut) also closes    /// the panel when it is already focused, instead of just moving focus back    /// to the editor.    ///    /// Default: false    pub close_panel_on_toggle: Option<bool>,    /// What draws window decorations/titlebar, the client application (Zed) or display server    /// Default: client    pub window_decorations: Option<WindowDecorations>,    /// Whether the focused panel follows the mouse location    /// Default: false    pub focus_follows_mouse: Option<FocusFollowsMouse>,} #[with_fallible_options]#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]pub struct ItemSettingsContent {    /// Whether to show the Git file status on a tab item.    ///    /// Default: false    pub git_status: Option<bool>,    /// Position of the close button in a tab.    ///    /// Default: right    pub close_position: Option<ClosePosition>,    /// Whether to show the file icon for a tab.    ///    /// Default: false    pub file_icons: Option<bool>,    /// What to do after closing the current tab.    ///    /// Default: history    pub activate_on_close: Option<ActivateOnClose>,    /// Which files containing diagnostic errors/warnings to mark in the tabs.    /// This setting can take the following three values:    ///    /// Default: off    pub show_diagnostics: Option<ShowDiagnostics>,    /// Whether to always show the close button on tabs.    ///    /// Default: false    pub show_close_button: Option<ShowCloseButton>,} #[with_fallible_options]#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]pub struct PreviewTabsSettingsContent {    /// Whether to show opened editors as preview tabs.    /// Preview tabs do not stay open, are reused until explicitly set to be kept open opened (via double-click or editing) and show file names in italic.    ///    /// Default: true    pub enabled: Option<bool>,    /// Whether to open tabs in preview mode when opened from the project panel with a single click.    ///    /// Default: true    pub enable_preview_from_project_panel: Option<bool>,    /// Whether to open tabs in preview mode when selected from the file finder.    ///    /// Default: false    pub enable_preview_from_file_finder: Option<bool>,    /// Whether to open tabs in preview mode when opened from a multibuffer.    ///    /// Default: true    pub enable_preview_from_multibuffer: Option<bool>,    /// Whether to open tabs in preview mode when code navigation is used to open a multibuffer.    ///    /// Default: false    pub enable_preview_multibuffer_from_code_navigation: Option<bool>,    /// Whether to open tabs in preview mode when code navigation is used to open a single file.    ///    /// Default: true    pub enable_preview_file_from_code_navigation: Option<bool>,    /// Whether to keep tabs in preview mode when code navigation is used to navigate away from them.    /// If `enable_preview_file_from_code_navigation` or `enable_preview_multibuffer_from_code_navigation` is also true, the new tab may replace the existing one.    ///    /// Default: false    pub enable_keep_preview_on_code_navigation: Option<bool>,} #[derive(    Copy,    Clone,    Debug,    PartialEq,    Default,    Serialize,    Deserialize,    JsonSchema,    MergeFrom,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "lowercase")]pub enum ClosePosition {    Left,    #[default]    Right,} #[derive(    Copy,    Clone,    Debug,    PartialEq,    Default,    Serialize,    Deserialize,    JsonSchema,    MergeFrom,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "lowercase")]pub enum ShowCloseButton {    Always,    #[default]    Hover,    Hidden,} #[derive(    Copy,    Clone,    Debug,    Default,    Serialize,    Deserialize,    JsonSchema,    MergeFrom,    PartialEq,    Eq,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum ShowDiagnostics {    #[default]    Off,    Errors,    All,} #[derive(    Copy,    Clone,    Debug,    PartialEq,    Default,    Serialize,    Deserialize,    JsonSchema,    MergeFrom,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum ActivateOnClose {    #[default]    History,    Neighbour,    LeftNeighbour,} #[with_fallible_options]#[derive(Copy, Clone, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]#[serde(rename_all = "snake_case")]pub struct ActivePaneModifiers {    /// Size of the border surrounding the active pane.    /// When set to 0, the active pane doesn't have any border.    /// The border is drawn inset.    ///    /// Default: `0.0`    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]    pub border_size: Option<f32>,    /// Opacity of inactive panels.    /// When set to 1.0, the inactive panes have the same opacity as the active one.    /// If set to 0, the inactive panes content will not be visible at all.    /// Values are clamped to the [0.0, 1.0] range.    ///    /// Default: `1.0`    #[schemars(range(min = 0.0, max = 1.0))]    pub inactive_opacity: Option<InactiveOpacity>,} #[derive(    Copy,    Clone,    Debug,    Default,    Serialize,    Deserialize,    PartialEq,    JsonSchema,    MergeFrom,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum BottomDockLayout {    /// Contained between the left and right docks    #[default]    Contained,    /// Takes up the full width of the window    Full,    /// Extends under the left dock while snapping to the right dock    LeftAligned,    /// Extends under the right dock while snapping to the left dock    RightAligned,} #[derive(    Copy,    Clone,    Default,    Debug,    Serialize,    Deserialize,    PartialEq,    JsonSchema,    MergeFrom,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum WindowDecorations {    /// Zed draws its own window decorations/titlebar (client-side decoration)    #[default]    Client,    /// Show system's window titlebar (server-side decoration; not supported by GNOME Wayland)    Server,} #[derive(    Copy,    Clone,    PartialEq,    Default,    Serialize,    Deserialize,    JsonSchema,    MergeFrom,    Debug,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum CloseWindowWhenNoItems {    /// Match platform conventions by default, so "on" on macOS and "off" everywhere else    #[default]    PlatformDefault,    /// Close the window when there are no tabs    CloseWindow,    /// Leave the window open when there are no tabs    KeepWindowOpen,} impl CloseWindowWhenNoItems {    pub fn should_close(&self) -> bool {        match self {            CloseWindowWhenNoItems::PlatformDefault => cfg!(target_os = "macos"),            CloseWindowWhenNoItems::CloseWindow => true,            CloseWindowWhenNoItems::KeepWindowOpen => false,        }    }} #[derive(    Copy,    Clone,    PartialEq,    Eq,    Default,    Serialize,    Deserialize,    JsonSchema,    MergeFrom,    Debug,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum RestoreOnStartupBehavior {    /// Always start with an empty editor tab    #[serde(alias = "none")]    EmptyTab,    /// Restore the workspace that was closed last.    LastWorkspace,    /// Restore all workspaces that were open when quitting Zed.    #[default]    LastSession,    /// Show the launchpad with recent projects (no tabs).    Launchpad,} #[with_fallible_options]#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]pub struct TabBarSettingsContent {    /// Whether or not to show the tab bar in the editor.    ///    /// Default: true    pub show: Option<bool>,    /// Whether or not to show the navigation history buttons in the tab bar.    ///    /// Default: true    pub show_nav_history_buttons: Option<bool>,    /// Whether or not to show the tab bar buttons.    ///    /// Default: true    pub show_tab_bar_buttons: Option<bool>,    /// Whether or not to show pinned tabs in a separate row.    /// When enabled, pinned tabs appear in a top row and unpinned tabs in a bottom row.    ///    /// Default: false    pub show_pinned_tabs_in_separate_row: Option<bool>,} #[with_fallible_options]#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq, Eq)]pub struct StatusBarSettingsContent {    /// Whether to show the status bar.    ///    /// Default: true    #[serde(rename = "experimental.show")]    pub show: Option<bool>,    /// Whether to show the name of the active file in the status bar.    ///    /// Default: false    pub show_active_file: Option<bool>,    /// Whether to display the active language button in the status bar.    ///    /// Default: true    pub active_language_button: Option<bool>,    /// Whether to show the cursor position button in the status bar.    ///    /// Default: true    pub cursor_position_button: Option<bool>,    /// Whether to show active line endings button in the status bar.    ///    /// Default: false    pub line_endings_button: Option<bool>,    /// Whether to show the active encoding button in the status bar.    ///    /// Default: non_utf8    pub active_encoding_button: Option<EncodingDisplayOptions>,} #[derive(    Copy,    Clone,    Debug,    Eq,    PartialEq,    Default,    Serialize,    Deserialize,    JsonSchema,    MergeFrom,    strum::VariantNames,    strum::VariantArray,)]#[serde(rename_all = "snake_case")]pub enum EncodingDisplayOptions {    Enabled,    Disabled,    #[default]    NonUtf8,}impl EncodingDisplayOptions {    pub fn should_show(&self, is_utf8: bool, has_bom: bool) -> bool {        match self {            Self::Disabled => false,            Self::Enabled => true,            Self::NonUtf8 => {                let is_standard_utf8 = is_utf8 && !has_bom;                !is_standard_utf8            }        }    }} #[derive(    Copy,    Clone,    Debug,    Serialize,

Lines 1–500 of 998.