extension.rs

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