1use anyhow::Result;
2use collections::HashMap;
3use gpui::AppContext;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use settings::{Settings, SettingsSources};
7use std::sync::Arc;
8
9#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema)]
10pub struct ExtensionSettings {
11 #[serde(default)]
12 pub auto_update_extensions: HashMap<Arc<str>, bool>,
13}
14
15impl ExtensionSettings {
16 pub fn should_auto_update(&self, extension_id: &str) -> bool {
17 self.auto_update_extensions
18 .get(extension_id)
19 .copied()
20 .unwrap_or(true)
21 }
22}
23
24impl Settings for ExtensionSettings {
25 const KEY: Option<&'static str> = None;
26
27 type FileContent = Self;
28
29 fn load(sources: SettingsSources<Self::FileContent>, _cx: &mut AppContext) -> Result<Self> {
30 Ok(sources.user.cloned().unwrap_or_default())
31 }
32}