1use collections::HashMap;
2use gpui::App;
3use settings::Settings;
4use std::sync::Arc;
5
6#[derive(Debug, Default, Clone)]
7pub struct ExtensionSettings {
8 /// The extensions that should be automatically installed by Zed.
9 ///
10 /// This is used to make functionality provided by extensions (e.g., language support)
11 /// available out-of-the-box.
12 ///
13 /// Default: { "html": true }
14 pub auto_install_extensions: HashMap<Arc<str>, bool>,
15 pub auto_update_extensions: HashMap<Arc<str>, bool>,
16}
17
18impl ExtensionSettings {
19 /// Returns whether the given extension should be auto-installed.
20 pub fn should_auto_install(&self, extension_id: &str) -> bool {
21 self.auto_install_extensions
22 .get(extension_id)
23 .copied()
24 .unwrap_or(true)
25 }
26
27 pub fn should_auto_update(&self, extension_id: &str) -> bool {
28 self.auto_update_extensions
29 .get(extension_id)
30 .copied()
31 .unwrap_or(true)
32 }
33}
34
35impl Settings for ExtensionSettings {
36 fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
37 Self {
38 auto_install_extensions: content.extension.auto_install_extensions.clone(),
39 auto_update_extensions: content.extension.auto_update_extensions.clone(),
40 }
41 }
42}