mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-29 21:49:33 +00:00
675ae24964
This PR adds an `zed: Install Local Extension` action, which lets you select a path to a folder containing a Zed extension, and install that . When you select a directory, the extension will be compiled (both the Tree-sitter grammars and the Rust code for the extension itself) and installed as a Zed extension, using a symlink. ### Details A few dependencies are needed to build an extension: * The Rust `wasm32-wasi` target. This is automatically installed if needed via `rustup`. * A wasi-preview1 adapter WASM module, for building WASM components with Rust. This is automatically downloaded if needed from a `wasmtime` GitHub release * For building Tree-sitter parsers, a distribution of `wasi-sdk`. This is automatically downloaded if needed from a `wasi-sdk` GitHub release. The downloaded artifacts are cached in a support directory called `Zed/extensions/build`. ### Tasks UX * [x] Show local extensions in the Extensions view * [x] Provide a button for recompiling a linked extension * [x] Make this action discoverable by adding a button for it on the Extensions view * [ ] Surface errors (don't just write them to the Zed log) Packaging * [ ] Create a separate executable that performs the extension compilation. We'll switch the packaging system in our [extensions](https://github.com/zed-industries/extensions) repo to use this binary, so that there is one canonical definition of how to build/package an extensions. ### Release Notes: - N/A --------- Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
72 lines
2 KiB
Rust
72 lines
2 KiB
Rust
use collections::BTreeMap;
|
|
use language::LanguageServerName;
|
|
use serde::{Deserialize, Serialize};
|
|
use std::{path::PathBuf, sync::Arc};
|
|
|
|
/// This is the old version of the extension manifest, from when it was `extension.json`.
|
|
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
|
|
pub struct OldExtensionManifest {
|
|
pub name: String,
|
|
pub version: Arc<str>,
|
|
|
|
#[serde(default)]
|
|
pub description: Option<String>,
|
|
#[serde(default)]
|
|
pub repository: Option<String>,
|
|
#[serde(default)]
|
|
pub authors: Vec<String>,
|
|
|
|
#[serde(default)]
|
|
pub themes: BTreeMap<Arc<str>, PathBuf>,
|
|
#[serde(default)]
|
|
pub languages: BTreeMap<Arc<str>, PathBuf>,
|
|
#[serde(default)]
|
|
pub grammars: BTreeMap<Arc<str>, PathBuf>,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
|
|
pub struct ExtensionManifest {
|
|
pub id: Arc<str>,
|
|
pub name: String,
|
|
pub version: Arc<str>,
|
|
|
|
#[serde(default)]
|
|
pub description: Option<String>,
|
|
#[serde(default)]
|
|
pub repository: Option<String>,
|
|
#[serde(default)]
|
|
pub authors: Vec<String>,
|
|
#[serde(default)]
|
|
pub lib: LibManifestEntry,
|
|
|
|
#[serde(default)]
|
|
pub themes: Vec<PathBuf>,
|
|
#[serde(default)]
|
|
pub languages: Vec<PathBuf>,
|
|
#[serde(default)]
|
|
pub grammars: BTreeMap<Arc<str>, GrammarManifestEntry>,
|
|
#[serde(default)]
|
|
pub language_servers: BTreeMap<LanguageServerName, LanguageServerManifestEntry>,
|
|
}
|
|
|
|
#[derive(Clone, Default, PartialEq, Eq, Debug, Deserialize, Serialize)]
|
|
pub struct LibManifestEntry {
|
|
pub kind: Option<ExtensionLibraryKind>,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
|
|
pub enum ExtensionLibraryKind {
|
|
Rust,
|
|
}
|
|
|
|
#[derive(Clone, Default, PartialEq, Eq, Debug, Deserialize, Serialize)]
|
|
pub struct GrammarManifestEntry {
|
|
pub repository: String,
|
|
#[serde(alias = "commit")]
|
|
pub rev: String,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
|
|
pub struct LanguageServerManifestEntry {
|
|
pub language: Arc<str>,
|
|
}
|