Fallible Settings (#42938)

Also tidies up error notifications so that in the case of syntax errors
we don't see noise about the migration failing as well.

Release Notes:

- Invalid values in settings files will no longer prevent the rest of
the file from being parsed.
This commit is contained in:
Conrad Irwin
2025-11-21 08:28:17 -07:00
committed by GitHub
parent a8d7f06b47
commit 2ac13b9489
19 changed files with 509 additions and 494 deletions
+9 -10
View File
@@ -2,13 +2,12 @@ use collections::{HashMap, IndexMap};
use gpui::SharedString;
use schemars::{JsonSchema, json_schema};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use settings_macros::MergeFrom;
use settings_macros::{MergeFrom, with_fallible_options};
use std::{borrow::Cow, path::PathBuf, sync::Arc};
use crate::DockPosition;
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, Default)]
pub struct AgentSettingsContent {
/// Whether the Agent is enabled.
@@ -166,7 +165,7 @@ impl AgentSettingsContent {
}
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct AgentProfileContent {
pub name: Arc<str>,
@@ -180,7 +179,7 @@ pub struct AgentProfileContent {
pub default_model: Option<LanguageModelSelection>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct ContextServerPresetContent {
pub tools: IndexMap<Arc<str>, bool>,
@@ -215,7 +214,7 @@ pub enum NotifyWhenAgentWaiting {
Never,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
pub struct LanguageModelSelection {
pub provider: LanguageModelProviderSetting,
@@ -231,7 +230,7 @@ pub enum CompletionMode {
Burn,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
pub struct LanguageModelParameters {
pub provider: Option<LanguageModelProviderSetting>,
@@ -290,7 +289,7 @@ impl From<&str> for LanguageModelProviderSetting {
}
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, PartialEq, Deserialize, Serialize, Clone, JsonSchema, MergeFrom, Debug)]
pub struct AllAgentServersSettings {
pub gemini: Option<BuiltinAgentServerSettings>,
@@ -302,7 +301,7 @@ pub struct AllAgentServersSettings {
pub custom: HashMap<SharedString, CustomAgentServerSettings>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Deserialize, Serialize, Clone, JsonSchema, MergeFrom, Debug, PartialEq)]
pub struct BuiltinAgentServerSettings {
/// Absolute path to a binary to be used when launching this agent.
@@ -340,7 +339,7 @@ pub struct BuiltinAgentServerSettings {
pub default_model: Option<String>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Deserialize, Serialize, Clone, JsonSchema, MergeFrom, Debug, PartialEq)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum CustomAgentServerSettings {
+11 -12
View File
@@ -4,14 +4,13 @@ use std::num;
use collections::HashMap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use settings_macros::MergeFrom;
use settings_macros::{MergeFrom, with_fallible_options};
use crate::{
DelayMs, DiagnosticSeverityContent, ShowScrollbar, serialize_f32_with_two_decimal_places,
};
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct EditorSettingsContent {
/// Whether the cursor blinks in the editor.
@@ -254,7 +253,7 @@ impl RelativeLineNumbers {
}
// Toolbar related settings
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
pub struct ToolbarContent {
/// Whether to display breadcrumbs in the editor toolbar.
@@ -281,7 +280,7 @@ pub struct ToolbarContent {
}
/// Scrollbar related settings
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
pub struct ScrollbarContent {
/// When to show the scrollbar in the editor.
@@ -317,7 +316,7 @@ pub struct ScrollbarContent {
}
/// Sticky scroll related settings
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
pub struct StickyScrollContent {
/// Whether sticky scroll is enabled.
@@ -327,7 +326,7 @@ pub struct StickyScrollContent {
}
/// Minimap related settings
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
pub struct MinimapContent {
/// When to show the minimap in the editor.
@@ -362,7 +361,7 @@ pub struct MinimapContent {
}
/// Forcefully enable or disable the scrollbar for each axis
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
pub struct ScrollbarAxesContent {
/// When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings.
@@ -377,7 +376,7 @@ pub struct ScrollbarAxesContent {
}
/// Gutter related settings
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
pub struct GutterContent {
/// Whether to show line numbers in the gutter.
@@ -754,7 +753,7 @@ pub enum SnippetSortOrder {
}
/// Default options for buffer and project search items.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
pub struct SearchSettingsContent {
/// Whether to show the project search button in the status bar.
@@ -771,7 +770,7 @@ pub struct SearchSettingsContent {
pub center_on_match: Option<bool>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)]
#[serde(rename_all = "snake_case")]
pub struct JupyterContent {
@@ -787,7 +786,7 @@ pub struct JupyterContent {
}
/// Whether to allow drag and drop text selection in buffer.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
pub struct DragAndDropSelectionContent {
/// When true, enables drag and drop text selection in buffer.
@@ -3,10 +3,9 @@ use std::sync::Arc;
use collections::HashMap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use settings_macros::MergeFrom;
use settings_macros::{MergeFrom, with_fallible_options};
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct ExtensionSettingsContent {
/// The extensions that should be automatically installed by Zed.
@@ -20,7 +19,6 @@ pub struct ExtensionSettingsContent {
#[serde(default)]
pub auto_update_extensions: HashMap<Arc<str>, bool>,
/// The capabilities granted to extensions.
#[serde(default)]
pub granted_extension_capabilities: Option<Vec<ExtensionCapabilityContent>>,
}
@@ -4,20 +4,17 @@ use collections::{HashMap, HashSet};
use gpui::{Modifiers, SharedString};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize, de::Error as _};
use serde_with::skip_serializing_none;
use settings_macros::MergeFrom;
use settings_macros::{MergeFrom, with_fallible_options};
use std::sync::Arc;
use crate::{ExtendingVec, merge_from};
#[skip_serializing_none]
#[with_fallible_options]
#[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)]
@@ -59,7 +56,7 @@ impl merge_from::MergeFrom for AllLanguageSettingsContent {
}
/// The settings for enabling/disabling features.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
#[serde(rename_all = "snake_case")]
pub struct FeaturesContent {
@@ -134,7 +131,7 @@ impl EditPredictionProvider {
}
/// The contents of the edit prediction settings.
#[skip_serializing_none]
#[with_fallible_options]
#[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.
@@ -153,7 +150,7 @@ pub struct EditPredictionSettingsContent {
pub enabled_in_text_threads: Option<bool>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
pub struct CopilotSettingsContent {
/// HTTP/HTTPS proxy to use for Copilot.
@@ -246,7 +243,7 @@ pub enum SoftWrap {
}
/// The settings for a particular language.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct LanguageSettingsContent {
/// How many columns a tab should occupy.
@@ -451,7 +448,7 @@ pub enum ShowWhitespaceSetting {
Trailing,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
pub struct WhitespaceMapContent {
pub space: Option<char>,
@@ -483,7 +480,7 @@ pub enum RewrapBehavior {
Anywhere,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct JsxTagAutoCloseSettingsContent {
/// Enables or disables auto-closing of JSX tags.
@@ -491,7 +488,7 @@ pub struct JsxTagAutoCloseSettingsContent {
}
/// The settings for inlay hints.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
pub struct InlayHintSettingsContent {
/// Global switch to toggle hints on and off.
@@ -573,7 +570,7 @@ impl InlayHintKind {
}
/// Controls how completions are processed for this language.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom, Default)]
#[serde(rename_all = "snake_case")]
pub struct CompletionSettingsContent {
@@ -658,7 +655,7 @@ pub enum WordsCompletionMode {
/// Allows to enable/disable formatting with Prettier
/// and configure default Prettier, used when no project-level Prettier installation is found.
/// Prettier formatting is disabled by default.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct PrettierSettingsContent {
/// Enables or disables formatting with Prettier for a given language.
@@ -812,7 +809,7 @@ struct LanguageServerSpecifierContent {
}
/// The settings for indent guides.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct IndentGuideSettingsContent {
/// Whether to display indent guides in the editor.
@@ -838,7 +835,7 @@ pub struct IndentGuideSettingsContent {
}
/// The task settings for a particular language.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Serialize, JsonSchema, MergeFrom)]
pub struct LanguageTaskSettingsContent {
/// Extra task variables to set for a particular language.
@@ -855,7 +852,7 @@ pub struct LanguageTaskSettingsContent {
}
/// Map from language name to settings.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct LanguageToSettingsMap(pub HashMap<SharedString, LanguageSettingsContent>);
@@ -911,6 +908,9 @@ pub enum IndentGuideBackgroundColoring {
#[cfg(test)]
mod test {
use crate::{ParseStatus, fallible_options};
use super::*;
#[test]
@@ -970,8 +970,8 @@ mod test {
#[test]
fn test_formatter_deserialization_invalid() {
let raw_auto = "{\"formatter\": {}}";
let result: Result<LanguageSettingsContent, _> = serde_json::from_str(raw_auto);
assert!(result.is_err());
let (_, result) = fallible_options::parse_json::<LanguageSettingsContent>(raw_auto);
assert!(matches!(result, ParseStatus::Failed { .. }));
}
#[test]
@@ -1,12 +1,11 @@
use collections::HashMap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use settings_macros::MergeFrom;
use settings_macros::{MergeFrom, with_fallible_options};
use std::sync::Arc;
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct AllLanguageModelSettingsContent {
pub anthropic: Option<AnthropicSettingsContent>,
@@ -25,14 +24,14 @@ pub struct AllLanguageModelSettingsContent {
pub zed_dot_dev: Option<ZedDotDevSettingsContent>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct AnthropicSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<AnthropicAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct AnthropicAvailableModel {
/// The model's name in the Anthropic API. e.g. claude-3-5-sonnet-latest, claude-3-opus-20240229, etc
@@ -54,7 +53,7 @@ pub struct AnthropicAvailableModel {
pub mode: Option<ModelMode>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct AmazonBedrockSettingsContent {
pub available_models: Option<Vec<BedrockAvailableModel>>,
@@ -64,7 +63,7 @@ pub struct AmazonBedrockSettingsContent {
pub authentication_method: Option<BedrockAuthMethodContent>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct BedrockAvailableModel {
pub name: String,
@@ -88,14 +87,14 @@ pub enum BedrockAuthMethodContent {
Automatic,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct OllamaSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<OllamaAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct OllamaAvailableModel {
/// The model name in the Ollama API (e.g. "llama3.2:latest")
@@ -136,14 +135,14 @@ impl Default for KeepAlive {
}
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct LmStudioSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<LmStudioAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct LmStudioAvailableModel {
pub name: String,
@@ -153,14 +152,14 @@ pub struct LmStudioAvailableModel {
pub supports_images: bool,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct DeepseekSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<DeepseekAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct DeepseekAvailableModel {
pub name: String,
@@ -169,14 +168,14 @@ pub struct DeepseekAvailableModel {
pub max_output_tokens: Option<u64>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct MistralSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<MistralAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct MistralAvailableModel {
pub name: String,
@@ -189,14 +188,14 @@ pub struct MistralAvailableModel {
pub supports_thinking: Option<bool>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct OpenAiSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<OpenAiAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct OpenAiAvailableModel {
pub name: String,
@@ -216,14 +215,14 @@ pub enum OpenAiReasoningEffort {
High,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct OpenAiCompatibleSettingsContent {
pub api_url: String,
pub available_models: Vec<OpenAiCompatibleAvailableModel>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct OpenAiCompatibleAvailableModel {
pub name: String,
@@ -235,7 +234,7 @@ pub struct OpenAiCompatibleAvailableModel {
pub capabilities: OpenAiCompatibleModelCapabilities,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct OpenAiCompatibleModelCapabilities {
pub tools: bool,
@@ -255,14 +254,14 @@ impl Default for OpenAiCompatibleModelCapabilities {
}
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct VercelSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<VercelAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct VercelAvailableModel {
pub name: String,
@@ -272,14 +271,14 @@ pub struct VercelAvailableModel {
pub max_completion_tokens: Option<u64>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct GoogleSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<GoogleAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct GoogleAvailableModel {
pub name: String,
@@ -288,14 +287,14 @@ pub struct GoogleAvailableModel {
pub mode: Option<ModelMode>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct XAiSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<XaiAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct XaiAvailableModel {
pub name: String,
@@ -308,13 +307,13 @@ pub struct XaiAvailableModel {
pub parallel_tool_calls: Option<bool>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct ZedDotDevSettingsContent {
pub available_models: Option<Vec<ZedDotDevAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct ZedDotDevAvailableModel {
/// The provider of the language model.
@@ -351,14 +350,14 @@ pub enum ZedDotDevAvailableProvider {
Google,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
pub struct OpenRouterSettingsContent {
pub api_url: Option<String>,
pub available_models: Option<Vec<OpenRouterAvailableModel>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct OpenRouterAvailableModel {
pub name: String,
@@ -372,7 +371,7 @@ pub struct OpenRouterAvailableModel {
pub provider: Option<OpenRouterProvider>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct OpenRouterProvider {
order: Option<Vec<String>>,
@@ -401,7 +400,7 @@ fn default_true() -> bool {
}
/// Configuration for caching language model messages.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct LanguageModelCacheConfiguration {
pub max_cache_anchors: usize,
+20 -25
View File
@@ -3,8 +3,7 @@ use std::{path::PathBuf, sync::Arc};
use collections::{BTreeMap, HashMap};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use settings_macros::MergeFrom;
use settings_macros::{MergeFrom, with_fallible_options};
use util::serde::default_true;
use crate::{
@@ -12,7 +11,7 @@ use crate::{
SlashCommandSettings,
};
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct ProjectSettingsContent {
#[serde(flatten)]
@@ -32,7 +31,6 @@ pub struct ProjectSettingsContent {
#[serde(default)]
pub lsp: HashMap<Arc<str>, LspSettings>,
#[serde(default)]
pub terminal: Option<ProjectTerminalSettingsContent>,
/// Configuration for Debugger-related features
@@ -53,15 +51,13 @@ pub struct ProjectSettingsContent {
pub git_hosting_providers: Option<ExtendingVec<GitHostingProviderConfig>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct WorktreeSettingsContent {
/// The displayed name of this project. If not set or null, the root directory name
/// will be displayed.
///
/// Default: null
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub project_name: Option<String>,
/// Whether to prevent this project from being shared in public channels.
@@ -103,7 +99,7 @@ pub struct WorktreeSettingsContent {
pub hidden_files: Option<Vec<String>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom, Hash)]
#[serde(rename_all = "snake_case")]
pub struct LspSettings {
@@ -140,7 +136,7 @@ impl Default for LspSettings {
}
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(
Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom, Hash,
)]
@@ -151,7 +147,7 @@ pub struct BinarySettings {
pub ignore_system_version: Option<bool>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(
Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom, Hash,
)]
@@ -161,7 +157,7 @@ pub struct FetchSettings {
}
/// Common language server settings.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct GlobalLspSettingsContent {
/// Whether to show the LSP servers button in the status bar.
@@ -170,18 +166,16 @@ pub struct GlobalLspSettingsContent {
pub button: Option<bool>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom)]
#[serde(rename_all = "snake_case")]
pub struct DapSettingsContent {
pub binary: Option<String>,
#[serde(default)]
pub args: Option<Vec<String>>,
#[serde(default)]
pub env: Option<HashMap<String, String>>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(
Default, Copy, Clone, PartialEq, Eq, Debug, Serialize, Deserialize, JsonSchema, MergeFrom,
)]
@@ -249,7 +243,7 @@ impl ContextServerSettingsContent {
}
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, MergeFrom)]
pub struct ContextServerCommand {
#[serde(rename = "command")]
@@ -285,7 +279,7 @@ impl std::fmt::Debug for ContextServerCommand {
}
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Copy, Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct GitSettings {
/// Whether or not to show the git gutter.
@@ -339,7 +333,7 @@ pub enum GitGutterSetting {
Hide,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Copy, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
#[serde(rename_all = "snake_case")]
pub struct InlineBlameSettings {
@@ -368,7 +362,7 @@ pub struct InlineBlameSettings {
pub show_commit_summary: Option<bool>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Copy, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
#[serde(rename_all = "snake_case")]
pub struct BlameSettings {
@@ -378,7 +372,7 @@ pub struct BlameSettings {
pub show_avatar: Option<bool>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Copy, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
#[serde(rename_all = "snake_case")]
pub struct BranchPickerSettingsContent {
@@ -410,6 +404,7 @@ pub enum GitHunkStyleSetting {
UnstagedHollow,
}
#[with_fallible_options]
#[derive(
Copy,
Clone,
@@ -432,7 +427,7 @@ pub enum GitPathStyle {
FilePathFirst,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct DiagnosticsSettingsContent {
/// Whether to show the project diagnostics button in the status bar.
@@ -448,7 +443,7 @@ pub struct DiagnosticsSettingsContent {
pub inline: Option<InlineDiagnosticsSettingsContent>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(
Clone, Copy, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
)]
@@ -464,7 +459,7 @@ pub struct LspPullDiagnosticsSettingsContent {
pub debounce_ms: Option<DelayMs>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(
Clone, Copy, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Eq,
)]
@@ -493,7 +488,7 @@ pub struct InlineDiagnosticsSettingsContent {
pub max_severity: Option<DiagnosticSeverityContent>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct NodeBinarySettings {
/// The path to the Node binary.
@@ -541,7 +536,7 @@ pub enum DiagnosticSeverityContent {
}
/// A custom Git hosting provider.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct GitHostingProviderConfig {
/// The type of the provider.
@@ -4,8 +4,7 @@ use collections::HashMap;
use gpui::{AbsoluteLength, FontFeatures, SharedString, px};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use settings_macros::MergeFrom;
use settings_macros::{MergeFrom, with_fallible_options};
use crate::FontFamilyName;
@@ -32,7 +31,7 @@ pub struct ProjectTerminalSettingsContent {
pub detect_venv: Option<VenvSettings>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct TerminalSettingsContent {
#[serde(flatten)]
@@ -201,7 +200,7 @@ pub enum WorkingDirectory {
Always { directory: String },
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(
Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq, Default,
)]
@@ -339,7 +338,7 @@ pub enum AlternateScroll {
}
// Toolbar related settings
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
pub struct TerminalToolbarContent {
/// Whether to display the terminal title in breadcrumbs inside the terminal pane.
@@ -386,7 +385,7 @@ pub enum VenvSettings {
conda_manager: Option<CondaManager>,
},
}
#[skip_serializing_none]
#[with_fallible_options]
pub struct VenvSettingsContent<'a> {
pub activate_script: ActivateScript,
pub venv_name: &'a str,
+23 -33
View File
@@ -4,90 +4,72 @@ use schemars::{JsonSchema, JsonSchema_repr};
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;
use serde_repr::{Deserialize_repr, Serialize_repr};
use settings_macros::MergeFrom;
use settings_macros::{MergeFrom, with_fallible_options};
use std::{fmt::Display, sync::Arc};
use serde_with::skip_serializing_none;
use crate::serialize_f32_with_two_decimal_places;
/// Settings for rendering text in UI and text buffers.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct ThemeSettingsContent {
/// The default font size for text in the UI.
#[serde(default)]
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
pub ui_font_size: Option<f32>,
/// The name of a font to use for rendering in the UI.
#[serde(default)]
pub ui_font_family: Option<FontFamilyName>,
/// The font fallbacks to use for rendering in the UI.
#[serde(default)]
#[schemars(default = "default_font_fallbacks")]
#[schemars(extend("uniqueItems" = true))]
pub ui_font_fallbacks: Option<Vec<FontFamilyName>>,
/// The OpenType features to enable for text in the UI.
#[serde(default)]
#[schemars(default = "default_font_features")]
pub ui_font_features: Option<FontFeatures>,
/// The weight of the UI font in CSS units from 100 to 900.
#[serde(default)]
#[schemars(default = "default_buffer_font_weight")]
pub ui_font_weight: Option<FontWeight>,
/// The name of a font to use for rendering in text buffers.
#[serde(default)]
pub buffer_font_family: Option<FontFamilyName>,
/// The font fallbacks to use for rendering in text buffers.
#[serde(default)]
#[schemars(extend("uniqueItems" = true))]
pub buffer_font_fallbacks: Option<Vec<FontFamilyName>>,
/// The default font size for rendering in text buffers.
#[serde(default)]
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
pub buffer_font_size: Option<f32>,
/// The weight of the editor font in CSS units from 100 to 900.
#[serde(default)]
#[schemars(default = "default_buffer_font_weight")]
pub buffer_font_weight: Option<FontWeight>,
/// The buffer's line height.
#[serde(default)]
pub buffer_line_height: Option<BufferLineHeight>,
/// The OpenType features to enable for rendering in text buffers.
#[serde(default)]
#[schemars(default = "default_font_features")]
pub buffer_font_features: Option<FontFeatures>,
/// The font size for agent responses in the agent panel. Falls back to the UI font size if unset.
#[serde(default)]
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
pub agent_ui_font_size: Option<f32>,
/// The font size for user messages in the agent panel.
#[serde(default)]
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
pub agent_buffer_font_size: Option<f32>,
/// The name of the Zed theme to use.
#[serde(default)]
pub theme: Option<ThemeSelection>,
/// The name of the icon theme to use.
#[serde(default)]
pub icon_theme: Option<IconThemeSelection>,
/// UNSTABLE: Expect many elements to be broken.
///
// Controls the density of the UI.
#[serde(rename = "unstable.ui_density", default)]
#[serde(rename = "unstable.ui_density")]
pub ui_density: Option<UiDensity>,
/// How much to fade out unused code.
#[serde(default)]
#[schemars(range(min = 0.0, max = 0.9))]
pub unnecessary_code_fade: Option<CodeFade>,
/// EXPERIMENTAL: Overrides for the current theme.
///
/// These values will override the ones on the current theme specified in `theme`.
#[serde(rename = "experimental.theme_overrides", default)]
#[serde(rename = "experimental.theme_overrides")]
pub experimental_theme_overrides: Option<ThemeStyleContent>,
/// Overrides per theme
@@ -270,7 +252,7 @@ impl UiDensity {
}
/// Font family name.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
#[serde(transparent)]
pub struct FontFamilyName(pub Arc<str>);
@@ -345,11 +327,11 @@ where
}
/// The content of a serialized theme.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
#[serde(default)]
pub struct ThemeStyleContent {
#[serde(default, rename = "background.appearance")]
#[serde(rename = "background.appearance")]
pub window_background_appearance: Option<WindowBackgroundContent>,
#[serde(default)]
@@ -380,18 +362,18 @@ pub struct PlayerColorContent {
}
/// Theme name.
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
#[serde(transparent)]
pub struct ThemeName(pub Arc<str>);
/// Icon Theme Name
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
#[serde(transparent)]
pub struct IconThemeName(pub Arc<str>);
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
#[serde(default)]
pub struct ThemeColorsContent {
@@ -925,19 +907,27 @@ pub struct ThemeColorsContent {
pub vim_mode_text: Option<String>,
}
#[skip_serializing_none]
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
#[serde(default)]
pub struct HighlightStyleContent {
pub color: Option<String>,
#[serde(deserialize_with = "treat_error_as_none")]
#[serde(
skip_serializing_if = "Option::is_none",
deserialize_with = "treat_error_as_none"
)]
pub background_color: Option<String>,
#[serde(deserialize_with = "treat_error_as_none")]
#[serde(
skip_serializing_if = "Option::is_none",
deserialize_with = "treat_error_as_none"
)]
pub font_style: Option<FontStyleContent>,
#[serde(deserialize_with = "treat_error_as_none")]
#[serde(
skip_serializing_if = "Option::is_none",
deserialize_with = "treat_error_as_none"
)]
pub font_weight: Option<FontWeightContent>,
}
@@ -959,7 +949,7 @@ where
Ok(T::deserialize(value).ok())
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
#[serde(default)]
pub struct StatusColorsContent {
@@ -3,15 +3,14 @@ use std::num::NonZeroUsize;
use collections::HashMap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use settings_macros::MergeFrom;
use settings_macros::{MergeFrom, with_fallible_options};
use crate::{
CenteredPaddingSettings, DelayMs, DockPosition, DockSide, InactiveOpacity,
ScrollbarSettingsContent, ShowIndentGuides, serialize_optional_f32_with_two_decimal_places,
};
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct WorkspaceSettingsContent {
/// Active pane styling settings.
@@ -112,7 +111,7 @@ pub struct WorkspaceSettingsContent {
pub zoomed_padding: Option<bool>,
}
#[skip_serializing_none]
#[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.
@@ -142,7 +141,7 @@ pub struct ItemSettingsContent {
pub show_close_button: Option<ShowCloseButton>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
pub struct PreviewTabsSettingsContent {
/// Whether to show opened editors as preview tabs.
@@ -244,7 +243,7 @@ pub enum ActivateOnClose {
LeftNeighbour,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Copy, Clone, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
#[serde(rename_all = "snake_case")]
pub struct ActivePaneModifiers {
@@ -350,7 +349,7 @@ pub enum RestoreOnStartupBehavior {
LastSession,
}
#[skip_serializing_none]
#[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.
@@ -367,13 +366,13 @@ pub struct TabBarSettingsContent {
pub show_tab_bar_buttons: Option<bool>,
}
#[skip_serializing_none]
#[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", default)]
#[serde(rename = "experimental.show")]
pub show: Option<bool>,
/// Whether to display the active language button in the status bar.
///
@@ -465,7 +464,7 @@ pub enum PaneSplitDirectionVertical {
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Default)]
#[serde(rename_all = "snake_case")]
#[skip_serializing_none]
#[with_fallible_options]
pub struct CenteredLayoutSettings {
/// The relative width of the left padding of the central pane from the
/// workspace when the centered layout is used.
@@ -510,7 +509,7 @@ impl OnLastWindowClosed {
}
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
pub struct ProjectPanelAutoOpenSettings {
/// Whether to automatically open newly created files in the editor.
@@ -527,7 +526,7 @@ pub struct ProjectPanelAutoOpenSettings {
pub on_drop: Option<bool>,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
pub struct ProjectPanelSettingsContent {
/// Whether to show the project panel button in the status bar.
@@ -663,7 +662,7 @@ pub enum ProjectPanelSortMode {
FilesFirst,
}
#[skip_serializing_none]
#[with_fallible_options]
#[derive(
Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq, Default,
)]