953 lines · 31.5 KB · Rust
RawDownload
use std::num::NonZeroU32; use collections::{HashMap, HashSet};use gpui::{Modifiers, SharedString};use schemars::JsonSchema;use serde::{Deserialize, Serialize};use serde_with::skip_serializing_none;use settings_macros::MergeFrom;use std::sync::Arc; use crate::{ExtendingVec, merge_from}; #[skip_serializing_none]#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema)]pub struct AllLanguageSettingsContent {    /// The settings for enabling/disabling features.    #[serde(default)]    pub features: Option<FeaturesContent>,    /// The edit prediction settings.    #[serde(default)]    pub edit_predictions: Option<EditPredictionSettingsContent>,    /// The default language settings.    #[serde(flatten)]    pub defaults: LanguageSettingsContent,    /// The settings for individual languages.    #[serde(default)]    pub languages: LanguageToSettingsMap,    /// Settings for associating file extensions and filenames    /// with languages.    pub file_types: Option<HashMap<Arc<str>, ExtendingVec<String>>>,} impl merge_from::MergeFrom for AllLanguageSettingsContent {    fn merge_from(&mut self, other: &Self) {        self.file_types.merge_from(&other.file_types);        self.features.merge_from(&other.features);        self.edit_predictions.merge_from(&other.edit_predictions);         // A user's global settings override the default global settings and        // all default language-specific settings.        //        self.defaults.merge_from(&other.defaults);        for language_settings in self.languages.0.values_mut() {            language_settings.merge_from(&other.defaults);        }         // A user's language-specific settings override default language-specific settings.        for (language_name, user_language_settings) in &other.languages.0 {            if let Some(existing) = self.languages.0.get_mut(language_name) {                existing.merge_from(&user_language_settings);            } else {                let mut new_settings = self.defaults.clone();                new_settings.merge_from(&user_language_settings);                 self.languages.0.insert(language_name.clone(), new_settings);            }        }    }} /// The settings for enabling/disabling features.#[skip_serializing_none]#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]#[serde(rename_all = "snake_case")]pub struct FeaturesContent {    /// Determines which edit prediction provider to use.    pub edit_prediction_provider: Option<EditPredictionProvider>,} /// The provider that supplies edit predictions.#[derive(    Copy, Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom,)]#[serde(rename_all = "snake_case")]pub enum EditPredictionProvider {    None,    #[default]    Copilot,    Supermaven,    Zed,    Codestral,} impl EditPredictionProvider {    pub fn is_zed(&self) -> bool {        match self {            EditPredictionProvider::Zed => true,            EditPredictionProvider::None            | EditPredictionProvider::Copilot            | EditPredictionProvider::Supermaven            | EditPredictionProvider::Codestral => false,        }    }} /// The contents of the edit prediction settings.#[skip_serializing_none]#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]pub struct EditPredictionSettingsContent {    /// A list of globs representing files that edit predictions should be disabled for.    /// This list adds to a pre-existing, sensible default set of globs.    /// Any additional ones you add are combined with them.    pub disabled_globs: Option<Vec<String>>,    /// The mode used to display edit predictions in the buffer.    /// Provider support required.    pub mode: Option<EditPredictionsMode>,    /// Settings specific to GitHub Copilot.    pub copilot: Option<CopilotSettingsContent>,    /// Settings specific to Codestral.    pub codestral: Option<CodestralSettingsContent>,    /// Whether edit predictions are enabled in the assistant prompt editor.    /// This has no effect if globally disabled.    pub enabled_in_text_threads: Option<bool>,} #[skip_serializing_none]#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]pub struct CopilotSettingsContent {    /// HTTP/HTTPS proxy to use for Copilot.    ///    /// Default: none    pub proxy: Option<String>,    /// Disable certificate verification for the proxy (not recommended).    ///    /// Default: false    pub proxy_no_verify: Option<bool>,    /// Enterprise URI for Copilot.    ///    /// Default: none    pub enterprise_uri: Option<String>,} #[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]pub struct CodestralSettingsContent {    /// Model to use for completions.    ///    /// Default: "codestral-latest"    #[serde(default)]    pub model: Option<String>,    /// Maximum tokens to generate.    ///    /// Default: 150    #[serde(default)]    pub max_tokens: Option<u32>,    /// Api URL to use for completions.    ///    /// Default: "https://codestral.mistral.ai"    #[serde(default)]    pub api_url: Option<String>,} /// The mode in which edit predictions should be displayed.#[derive(    Copy,    Clone,    Debug,    Default,    Eq,    PartialEq,    Serialize,    Deserialize,    JsonSchema,    MergeFrom,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum EditPredictionsMode {    /// If provider supports it, display inline when holding modifier key (e.g., alt).    /// Otherwise, eager preview is used.    #[serde(alias = "auto")]    Subtle,    /// Display inline when there are no language server completions available.    #[default]    #[serde(alias = "eager_preview")]    Eager,} /// Controls the soft-wrapping behavior in the editor.#[derive(    Copy,    Clone,    Debug,    Serialize,    Deserialize,    PartialEq,    Eq,    JsonSchema,    MergeFrom,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum SoftWrap {    /// Prefer a single line generally, unless an overly long line is encountered.    None,    /// Deprecated: use None instead. Left to avoid breaking existing users' configs.    /// Prefer a single line generally, unless an overly long line is encountered.    PreferLine,    /// Soft wrap lines that exceed the editor width.    EditorWidth,    /// Soft wrap lines at the preferred line length.    PreferredLineLength,    /// Soft wrap line at the preferred line length or the editor width (whichever is smaller).    Bounded,} /// The settings for a particular language.#[skip_serializing_none]#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]pub struct LanguageSettingsContent {    /// How many columns a tab should occupy.    ///    /// Default: 4    #[schemars(range(min = 1, max = 128))]    pub tab_size: Option<NonZeroU32>,    /// Whether to indent lines using tab characters, as opposed to multiple    /// spaces.    ///    /// Default: false    pub hard_tabs: Option<bool>,    /// How to soft-wrap long lines of text.    ///    /// Default: none    pub soft_wrap: Option<SoftWrap>,    /// The column at which to soft-wrap lines, for buffers where soft-wrap    /// is enabled.    ///    /// Default: 80    pub preferred_line_length: Option<u32>,    /// Whether to show wrap guides in the editor. Setting this to true will    /// show a guide at the 'preferred_line_length' value if softwrap is set to    /// 'preferred_line_length', and will show any additional guides as specified    /// by the 'wrap_guides' setting.    ///    /// Default: true    pub show_wrap_guides: Option<bool>,    /// Character counts at which to show wrap guides in the editor.    ///    /// Default: []    pub wrap_guides: Option<Vec<usize>>,    /// Indent guide related settings.    pub indent_guides: Option<IndentGuideSettingsContent>,    /// Whether or not to perform a buffer format before saving.    ///    /// Default: on    pub format_on_save: Option<FormatOnSave>,    /// Whether or not to remove any trailing whitespace from lines of a buffer    /// before saving it.    ///    /// Default: true    pub remove_trailing_whitespace_on_save: Option<bool>,    /// Whether or not to ensure there's a single newline at the end of a buffer    /// when saving it.    ///    /// Default: true    pub ensure_final_newline_on_save: Option<bool>,    /// How to perform a buffer format.    ///    /// Default: auto    pub formatter: Option<FormatterList>,    /// Zed's Prettier integration settings.    /// Allows to enable/disable formatting with Prettier    /// and configure default Prettier, used when no project-level Prettier installation is found.    ///    /// Default: off    pub prettier: Option<PrettierSettingsContent>,    /// Whether to automatically close JSX tags.    pub jsx_tag_auto_close: Option<JsxTagAutoCloseSettingsContent>,    /// Whether to use language servers to provide code intelligence.    ///    /// Default: true    pub enable_language_server: Option<bool>,    /// The list of language servers to use (or disable) for this language.    ///    /// This array should consist of language server IDs, as well as the following    /// special tokens:    /// - `"!<language_server_id>"` - A language server ID prefixed with a `!` will be disabled.    /// - `"..."` - A placeholder to refer to the **rest** of the registered language servers for this language.    ///    /// Default: ["..."]    pub language_servers: Option<Vec<String>>,    /// Controls where the `editor::Rewrap` action is allowed for this language.    ///    /// Note: This setting has no effect in Vim mode, as rewrap is already    /// allowed everywhere.    ///    /// Default: "in_comments"    pub allow_rewrap: Option<RewrapBehavior>,    /// Controls whether edit predictions are shown immediately (true)    /// or manually by triggering `editor::ShowEditPrediction` (false).    ///    /// Default: true    pub show_edit_predictions: Option<bool>,    /// Controls whether edit predictions are shown in the given language    /// scopes.    ///    /// Example: ["string", "comment"]    ///    /// Default: []    pub edit_predictions_disabled_in: Option<Vec<String>>,    /// Whether to show tabs and spaces in the editor.    pub show_whitespaces: Option<ShowWhitespaceSetting>,    /// Visible characters used to render whitespace when show_whitespaces is enabled.    ///    /// Default: "•" for spaces, "→" for tabs.    pub whitespace_map: Option<WhitespaceMapContent>,    /// Whether to start a new line with a comment when a previous line is a comment as well.    ///    /// Default: true    pub extend_comment_on_newline: Option<bool>,    /// Inlay hint related settings.    pub inlay_hints: Option<InlayHintSettingsContent>,    /// Whether to automatically type closing characters for you. For example,    /// when you type '(', Zed will automatically add a closing ')' at the correct position.    ///    /// Default: true    pub use_autoclose: Option<bool>,    /// Whether to automatically surround text with characters for you. For example,    /// when you select text and type '(', Zed will automatically surround text with ().    ///    /// Default: true    pub use_auto_surround: Option<bool>,    /// Controls how the editor handles the autoclosed characters.    /// When set to `false`(default), skipping over and auto-removing of the closing characters    /// happen only for auto-inserted characters.    /// Otherwise(when `true`), the closing characters are always skipped over and auto-removed    /// no matter how they were inserted.    ///    /// Default: false    pub always_treat_brackets_as_autoclosed: Option<bool>,    /// 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>,    /// Which code actions to run on save after the formatter.    /// These are not run if formatting is off.    ///    /// Default: {} (or {"source.organizeImports": true} for Go).    pub code_actions_on_format: Option<HashMap<String, bool>>,    /// Whether to perform linked edits of associated ranges, if the language server supports it.    /// For example, when editing opening <html> tag, the contents of the closing </html> tag will be edited as well.    ///    /// Default: true    pub linked_edits: Option<bool>,    /// Whether indentation should be adjusted based on the context whilst typing.    ///    /// Default: true    pub auto_indent: Option<bool>,    /// Whether indentation of pasted content should be adjusted based on the context.    ///    /// Default: true    pub auto_indent_on_paste: Option<bool>,    /// Task configuration for this language.    ///    /// Default: {}    pub tasks: Option<LanguageTaskSettingsContent>,    /// 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>,    /// Controls how completions are processed for this language.    pub completions: Option<CompletionSettingsContent>,    /// Preferred debuggers for this language.    ///    /// Default: []    pub debuggers: Option<Vec<String>>,} /// Controls how whitespace should be displayedin the editor.#[derive(    Copy,    Clone,    Debug,    Serialize,    Deserialize,    PartialEq,    Eq,    JsonSchema,    MergeFrom,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum ShowWhitespaceSetting {    /// Draw whitespace only for the selected text.    Selection,    /// Do not draw any tabs or spaces.    None,    /// Draw all invisible symbols.    All,    /// Draw whitespaces at boundaries only.    ///    /// For a whitespace to be on a boundary, any of the following conditions need to be met:    /// - It is a tab    /// - It is adjacent to an edge (start or end)    /// - It is adjacent to a whitespace (left or right)    Boundary,    /// Draw whitespaces only after non-whitespace characters.    Trailing,} #[skip_serializing_none]#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]pub struct WhitespaceMapContent {    pub space: Option<char>,    pub tab: Option<char>,} /// The behavior of `editor::Rewrap`.#[derive(    Debug,    PartialEq,    Clone,    Copy,    Default,    Serialize,    Deserialize,    JsonSchema,    MergeFrom,    strum::VariantArray,    strum::VariantNames,)]#[serde(rename_all = "snake_case")]pub enum RewrapBehavior {    /// Only rewrap within comments.    #[default]    InComments,    /// Only rewrap within the current selection(s).    InSelections,    /// Allow rewrapping anywhere.    Anywhere,} #[skip_serializing_none]#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom)]pub struct JsxTagAutoCloseSettingsContent {    /// Enables or disables auto-closing of JSX tags.    pub enabled: Option<bool>,} /// The settings for inlay hints.#[skip_serializing_none]#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]pub struct InlayHintSettingsContent {    /// Global switch to toggle hints on and off.    ///    /// Default: false    pub enabled: Option<bool>,    /// Global switch to toggle inline values on and off when debugging.    ///    /// Default: true    pub show_value_hints: Option<bool>,    /// Whether type hints should be shown.    ///    /// Default: true    pub show_type_hints: Option<bool>,    /// Whether parameter hints should be shown.    ///    /// Default: true    pub show_parameter_hints: Option<bool>,    /// Whether other hints should be shown.    ///    /// Default: true    pub show_other_hints: Option<bool>,    /// Whether to show a background for inlay hints.    ///    /// If set to `true`, the background will use the `hint.background` color    /// from the current theme.    ///    /// Default: false    pub show_background: Option<bool>,    /// Whether or not to debounce inlay hints updates after buffer edits.    ///    /// Set to 0 to disable debouncing.    ///    /// Default: 700    pub edit_debounce_ms: Option<u64>,    /// Whether or not to debounce inlay hints updates after buffer scrolls.    ///    /// Set to 0 to disable debouncing.    ///    /// Default: 50    pub scroll_debounce_ms: Option<u64>,    /// Toggles inlay hints (hides or shows) when the user presses the modifiers specified.    /// If only a subset of the modifiers specified is pressed, hints are not toggled.    /// If no modifiers are specified, this is equivalent to `null`.    ///    /// Default: null    pub toggle_on_modifiers_press: Option<Modifiers>,} /// The kind of an inlay hint.

Lines 1–500 of 953.