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.0.1"
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- Open the extensions view using the `zed: extensions` action in the command palette.
55- Click the `Install Dev Extension` button in the top right
56- Choose the path to your extension directory.