Detailed changes
@@ -1,35 +1,32 @@
-use anyhow::Result;
use gpui::App;
-use schemars::JsonSchema;
-use serde::{Deserialize, Serialize};
-use settings::{Settings, SettingsKey, SettingsSources, SettingsUi};
+use settings::Settings;
use util::MergeFrom;
-#[derive(Deserialize, Debug)]
+#[derive(Debug)]
pub struct CallSettings {
pub mute_on_join: bool,
pub share_on_join: bool,
}
impl Settings for CallSettings {
- fn from_defaults(content: &settings::SettingsContent, cx: &mut App) -> Self {
- let call = content.call.unwrap();
+ fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
+ let call = content.calls.clone().unwrap();
CallSettings {
mute_on_join: call.mute_on_join.unwrap(),
share_on_join: call.share_on_join.unwrap(),
}
}
- fn refine(&mut self, content: &settings::SettingsContent, cx: &mut App) {
- if let Some(call) = content.call.clone() {
- self.mute_on_join.merge_from(call.mute_on_join);
- self.share_on_join.merge_from(call.share_on_join);
+ fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
+ if let Some(call) = content.calls.clone() {
+ self.mute_on_join.merge_from(&call.mute_on_join);
+ self.share_on_join.merge_from(&call.share_on_join);
}
}
fn import_from_vscode(
_vscode: &settings::VsCodeSettings,
- _current: &settings::SettingsContent,
+ _current: &mut settings::SettingsContent,
) {
}
}
@@ -1,13 +1,9 @@
-use anyhow::Result;
use collections::HashMap;
use gpui::App;
-use schemars::JsonSchema;
-use serde::{Deserialize, Serialize};
-use settings::{Settings, SettingsKey, SettingsSources, SettingsUi};
+use settings::Settings;
use std::sync::Arc;
-#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, SettingsUi, SettingsKey)]
-#[settings_key(None)]
+#[derive(Debug, Default, Clone)]
pub struct ExtensionSettings {
/// The extensions that should be automatically installed by Zed.
///
@@ -15,9 +11,7 @@ pub struct ExtensionSettings {
/// available out-of-the-box.
///
/// Default: { "html": true }
- #[serde(default)]
pub auto_install_extensions: HashMap<Arc<str>, bool>,
- #[serde(default)]
pub auto_update_extensions: HashMap<Arc<str>, bool>,
}
@@ -39,18 +33,24 @@ impl ExtensionSettings {
}
impl Settings for ExtensionSettings {
- type FileContent = Self;
+ fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
+ Self {
+ auto_install_extensions: content.extension.auto_install_extensions.clone(),
+ auto_update_extensions: content.extension.auto_update_extensions.clone(),
+ }
+ }
- fn load(sources: SettingsSources<Self::FileContent>, _cx: &mut App) -> Result<Self> {
- SettingsSources::<Self::FileContent>::json_merge_with(
- [sources.default]
- .into_iter()
- .chain(sources.user)
- .chain(sources.server),
- )
+ fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
+ self.auto_install_extensions
+ .extend(content.extension.auto_install_extensions.clone());
+ self.auto_update_extensions
+ .extend(content.extension.auto_update_extensions.clone());
}
- fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {
+ fn import_from_vscode(
+ _vscode: &settings::VsCodeSettings,
+ _current: &mut settings::SettingsContent,
+ ) {
// settingsSync.ignoredExtensions controls autoupdate for vscode extensions, but we
// don't have a mapping to zed-extensions. there's also extensions.autoCheckUpdates
// and extensions.autoUpdate which are global switches, we don't support those yet
@@ -312,8 +312,8 @@ pub fn init(languages: Arc<LanguageRegistry>, fs: Arc<dyn Fs>, node: NodeRuntime
SettingsStore::update_global(cx, |settings, cx| {
settings
.set_extension_settings(
- ExtensionsSettingsContent {
- languages: language_settings.clone(),
+ settings::ExtensionsSettingsContent {
+ all_languages: language_settings.clone(),
},
cx,
)
@@ -15,6 +15,7 @@ use release_channel::ReleaseChannel;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::env;
+use std::sync::Arc;
pub use util::serde::default_true;
use crate::ActiveSettingsProfileName;
@@ -27,6 +28,9 @@ pub struct SettingsContent {
#[serde(flatten)]
pub theme: ThemeSettingsContent,
+ #[serde(flatten)]
+ pub extension: ExtensionSettingsContent,
+
pub agent: Option<AgentSettingsContent>,
pub agent_servers: Option<AllAgentServersSettings>,
@@ -327,3 +331,17 @@ pub struct CallSettingsContent {
/// Default: false
pub share_on_join: Option<bool>,
}
+
+#[derive(Deserialize, Serialize, PartialEq, Debug, Default, Clone, JsonSchema)]
+pub struct ExtensionSettingsContent {
+ /// The extensions that should be automatically installed by Zed.
+ ///
+ /// This is used to make functionality provided by extensions (e.g., language support)
+ /// available out-of-the-box.
+ ///
+ /// Default: { "html": true }
+ #[serde(default)]
+ pub auto_install_extensions: HashMap<Arc<str>, bool>,
+ #[serde(default)]
+ pub auto_update_extensions: HashMap<Arc<str>, bool>,
+}