1# The Zed Rust Extension API
2
3This crate lets you write extensions for Zed in Rust.
4
5## Extension Manifest
6
7You'll need an `extension.toml` file at the root of your extension directory, with the following structure:
8
9```toml
10id = "my-extension"
11name = "My Extension"
12description = "..."
13version = "0.0.1"
14schema_version = 1
15authors = ["Your Name <you@example.com>"]
16repository = "https://github.com/your/extension-repository"
17```
18
19## Cargo metadata
20
21Zed extensions are packaged as WebAssembly files. In your Cargo.toml, you'll
22need to set your `crate-type` accordingly:
23
24```toml
25[dependencies]
26zed_extension_api = "0.6.0"
27
28[lib]
29crate-type = ["cdylib"]
30```
31
32## Implementing an Extension
33
34To define your extension, create a type that implements the `Extension` trait, and register it.
35
36```rust
37use zed_extension_api as zed;
38
39struct MyExtension {
40 // ... state
41}
42
43impl zed::Extension for MyExtension {
44 // ...
45}
46
47zed::register_extension!(MyExtension);
48```
49
50## Testing your extension
51
52To run your extension in Zed as you're developing it:
53
54- Make sure you have [Rust installed](https://www.rust-lang.org/learn/get-started)
55- Have the `wasm32-wasip2` target installed (`rustup target add wasm32-wasip2`)
56- Open the extensions view using the `zed: extensions` action in the command palette.
57- Click the `Install Dev Extension` button in the top right
58- Choose the path to your extension directory.
59
60## Compatible Zed versions
61
62Extensions created using newer versions of the Zed extension API won't be compatible with older versions of Zed.
63
64Here is the compatibility of the `zed_extension_api` with versions of Zed:
65
66| Zed version | `zed_extension_api` version |
67| ----------- | --------------------------- |
68| `0.192.x` | `0.0.1` - `0.6.0` |
69| `0.186.x` | `0.0.1` - `0.5.0` |
70| `0.184.x` | `0.0.1` - `0.4.0` |
71| `0.178.x` | `0.0.1` - `0.3.0` |
72| `0.162.x` | `0.0.1` - `0.2.0` |
73| `0.149.x` | `0.0.1` - `0.1.0` |
74| `0.131.x` | `0.0.1` - `0.0.6` |
75| `0.130.x` | `0.0.1` - `0.0.5` |
76| `0.129.x` | `0.0.1` - `0.0.4` |
77| `0.128.x` | `0.0.1` |