extension.rs

 1use std::sync::Arc;
 2
 3use collections::HashMap;
 4use schemars::JsonSchema;
 5use serde::{Deserialize, Serialize};
 6use serde_with::skip_serializing_none;
 7use settings_macros::MergeFrom;
 8
 9#[skip_serializing_none]
10#[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
11pub struct ExtensionSettingsContent {
12    /// The extensions that should be automatically installed by Zed.
13    ///
14    /// This is used to make functionality provided by extensions (e.g., language support)
15    /// available out-of-the-box.
16    ///
17    /// Default: { "html": true }
18    #[serde(default)]
19    pub auto_install_extensions: HashMap<Arc<str>, bool>,
20    #[serde(default)]
21    pub auto_update_extensions: HashMap<Arc<str>, bool>,
22    /// The capabilities granted to extensions.
23    #[serde(default)]
24    pub granted_extension_capabilities: Option<Vec<ExtensionCapabilityContent>>,
25}
26
27/// A capability for an extension.
28#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
29#[serde(tag = "kind", rename_all = "snake_case")]
30pub enum ExtensionCapabilityContent {
31    #[serde(rename = "process:exec")]
32    ProcessExec {
33        /// The command to execute.
34        command: String,
35        /// The arguments to pass to the command. Use `*` for a single wildcard argument.
36        /// If the last element is `**`, then any trailing arguments are allowed.
37        args: Vec<String>,
38    },
39    DownloadFile {
40        host: String,
41        path: Vec<String>,
42    },
43    #[serde(rename = "npm:install")]
44    NpmInstallPackage {
45        package: String,
46    },
47}