developing-extensions.md

  1# Developing Extensions
  2
  3## Extension Features
  4
  5Extensions are able to provide the following features to Zed:
  6
  7- [Languages](./languages.md)
  8- [Debuggers](./debugger-extensions.md)
  9- [Themes](./themes.md)
 10- [Icon Themes](./icon-themes.md)
 11- [Slash Commands](./slash-commands.md)
 12- [MCP Servers](./mcp-extensions.md)
 13
 14## Developing an Extension Locally
 15
 16Before starting to develop an extension for Zed, be sure to [install Rust via rustup](https://www.rust-lang.org/tools/install).
 17
 18> Rust must be installed via rustup. If you have Rust installed via homebrew or otherwise, installing dev extensions will not work.
 19
 20When developing an extension, you can use it in Zed without needing to publish it by installing it as a _dev extension_.
 21
 22From the extensions page, click the `Install Dev Extension` button (or the {#action zed::InstallDevExtension} action) and select the directory containing your extension.
 23
 24If you need to troubleshoot, you can check the Zed.log ({#action zed::OpenLog}) for additional output. For debug output, close and relaunch zed with the `zed --foreground` from the command line which show more verbose INFO level logging.
 25
 26If you already have the published version of the extension installed, the published version will be uninstalled prior to the installation of the dev extension. After successful installation, the `Extensions` page will indicate that the upstream extension is "Overridden by dev extension".
 27
 28## Directory Structure of a Zed Extension
 29
 30A Zed extension is a Git repository that contains an `extension.toml`. This file must contain some
 31basic information about the extension:
 32
 33```toml
 34id = "my-extension"
 35name = "My extension"
 36version = "0.0.1"
 37schema_version = 1
 38authors = ["Your Name <you@example.com>"]
 39description = "My cool extension"
 40repository = "https://github.com/your-name/my-zed-extension"
 41```
 42
 43> Note: If you are working on a theme extension with the intend of publishing it later, is is recommended that you suffix your theme's extension ID with `-theme`. This might otherwise be raised during the process of [releasing your extension](#publishing-your-extension).
 44
 45In addition to this, there are several other optional files and directories that can be used to add functionality to a Zed extension. An example directory structure of an extension that provides all capabilities is as follows:
 46
 47```
 48my-extension/
 49  extension.toml
 50  Cargo.toml
 51  src/
 52    lib.rs
 53  languages/
 54    my-language/
 55      config.toml
 56      highlights.scm
 57  themes/
 58    my-theme.json
 59```
 60
 61## WebAssembly
 62
 63Procedural parts of extensions are written in Rust and compiled to WebAssembly. To develop an extension that includes custom code, include a `Cargo.toml` like this:
 64
 65```toml
 66[package]
 67name = "my-extension"
 68version = "0.0.1"
 69edition = "2021"
 70
 71[lib]
 72crate-type = ["cdylib"]
 73
 74[dependencies]
 75zed_extension_api = "0.1.0"
 76```
 77
 78Use the latest version of the [`zed_extension_api`](https://crates.io/crates/zed_extension_api) available on crates.io. Make sure it's still [compatible with Zed versions](https://github.com/zed-industries/zed/blob/main/crates/extension_api#compatible-zed-versions) you want to support.
 79
 80In the `src/lib.rs` file in your Rust crate you will need to define a struct for your extension and implement the `Extension` trait, as well as use the `register_extension!` macro to register your extension:
 81
 82```rs
 83use zed_extension_api as zed;
 84
 85struct MyExtension {
 86    // ... state
 87}
 88
 89impl zed::Extension for MyExtension {
 90    // ...
 91}
 92
 93zed::register_extension!(MyExtension);
 94```
 95
 96> `stdout`/`stderr` is forwarded directly to the Zed process. In order to see `println!`/`dbg!` output from your extension, you can start Zed in your terminal with a `--foreground` flag.
 97
 98## Forking and cloning the repo
 99
1001. Fork the repo
101
102> Note: It is very helpful if you fork the `zed-industries/extensions` repo to a personal GitHub account instead of a GitHub organization, as this allows Zed staff to push any needed changes to your PR to expedite the publishing process.
103
1042. Clone the repo to your local machine
105
106```sh
107# Substitute the url of your fork here:
108# git clone https://github.com/zed-industries/extensions
109cd extensions
110git submodule init
111git submodule update
112```
113
114## Extension License Requirements
115
116As of October 1st, 2025, extension repositories must include a license.
117The following licenses are accepted:
118
119- [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
120- [BSD 2-Clause](https://opensource.org/license/bsd-2-clause)
121- [BSD 3-Clause](https://opensource.org/license/bsd-3-clause)
122- [GNU GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)
123- [GNU LGPLv3](https://www.gnu.org/licenses/lgpl-3.0.en.html)
124- [MIT](https://opensource.org/license/mit)
125- [zlib](https://opensource.org/license/zlib)
126
127This allows us to distribute the resulting binary produced from your extension code to our users.
128Without a valid license, the pull request to add or update your extension in the following steps will fail CI.
129
130Your license file should be at the root of your extension repository. Any filename that has `LICENCE` or `LICENSE` as a prefix (case insensitive) will be inspected to ensure it matches one of the accepted licenses. See the [license validation source code](https://github.com/zed-industries/extensions/blob/main/src/lib/license.js).
131
132> This license requirement applies only to your extension code itself (the code that gets compiled into the extension binary).
133> It does not apply to any tools your extension may download or interact with, such as language servers or other external dependencies.
134> If your repository contains both extension code and other projects (like a language server), you are not required to relicense those other projects—only the extension code needs to be one of the aforementioned accepted licenses.
135
136## Publishing your extension
137
138To publish an extension, open a PR to [the `zed-industries/extensions` repo](https://github.com/zed-industries/extensions).
139
140In your PR, do the following:
141
1421. Add your extension as a Git submodule within the `extensions/` directory
143
144```sh
145git submodule add https://github.com/your-username/foobar-zed.git extensions/foobar
146git add extensions/foobar
147```
148
149> All extension submodules must use HTTPS URLs and not SSH URLS (`git@github.com`).
150
1512. Add a new entry to the top-level `extensions.toml` file containing your extension:
152
153```toml
154[my-extension]
155submodule = "extensions/my-extension"
156version = "0.0.1"
157```
158
159> If your extension is in a subdirectory within the submodule you can use the `path` field to point to where the extension resides.
160
1613. Run `pnpm sort-extensions` to ensure `extensions.toml` and `.gitmodules` are sorted
162
163Once your PR is merged, the extension will be packaged and published to the Zed extension registry.
164
165> Extension IDs and names should not contain `zed` or `Zed`, since they are all Zed extensions.
166
167## Updating an extension
168
169To update an extension, open a PR to [the `zed-industries/extensions` repo](https://github.com/zed-industries/extensions).
170
171In your PR do the following:
172
1731. Update the extension's submodule to the commit of the new version. For this, you can run
174
175```sh
176# From the root of the repository:
177git submodule update --remote extensions/your-extension-name
178```
179
180to update your extension to the latest commit available in your remote repository.
181
1822. Update the `version` field for the extension in `extensions.toml`
183   - Make sure the `version` matches the one set in `extension.toml` at the particular commit.
184
185If you'd like to automate this process, there is a [community GitHub Action](https://github.com/huacnlee/zed-extension-action) you can use.
186
187> **Note:** If your extension repository has a different license, you'll need to update it to be one of the [accepted extension licenses](#extension-license-requirements) before publishing your update.