Files
oak-gpui/crates/extension_host/src/extension_settings.rs
T
fcdab160f9 Settings refactor (#38367)
Co-Authored-By: Ben K <ben@zed.dev>
Co-Authored-By: Anthony <anthony@zed.dev>
Co-Authored-By: Mikayla <mikayla@zed.dev>

Release Notes:

- settings: Major internal changes to settings. The primary user-facing
effect is that some settings which did not make sense in project
settings files are no-longer read from there. (For example the inline
blame settings)

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
Co-authored-by: Anthony <anthony@zed.dev>
2025-09-18 16:47:23 +00:00

59 lines
2.0 KiB
Rust

use collections::HashMap;
use gpui::App;
use settings::Settings;
use std::sync::Arc;
#[derive(Debug, Default, Clone)]
pub struct ExtensionSettings {
/// 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 }
pub auto_install_extensions: HashMap<Arc<str>, bool>,
pub auto_update_extensions: HashMap<Arc<str>, bool>,
}
impl ExtensionSettings {
/// Returns whether the given extension should be auto-installed.
pub fn should_auto_install(&self, extension_id: &str) -> bool {
self.auto_install_extensions
.get(extension_id)
.copied()
.unwrap_or(true)
}
pub fn should_auto_update(&self, extension_id: &str) -> bool {
self.auto_update_extensions
.get(extension_id)
.copied()
.unwrap_or(true)
}
}
impl Settings for ExtensionSettings {
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 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 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
}
}