antora-zed is the reason antora-ls exists. I wanted to write Antora documentation in Zed, and Zed had no idea what an xref: was. The two projects started in the same minute, as a pair.
Keeping the extension thin
Zed extensions are written in Rust and compiled to WebAssembly. They can't do much on their own, and that suits a language server design well: all the Antora logic lives in antora-ls, and the extension is around a hundred lines of Rust. It does three things:
- Finds the language server: a binary path from the Zed settings, then
antora-lson thePATH, then a previously downloaded copy, and finally the latest GitHub release for the platform, downloaded automatically. Older downloaded versions are removed. - Attaches it to AsciiDoc files, passing along the project's shell environment.
- Layers on top of Zed's AsciiDoc extension, which already handles syntax highlighting.
Because the extension downloads the latest antora-ls release, language server updates reach users without an extension update.
The payoff
The git history shows how well that worked. The extension's Rust code hasn't changed since its first commit. Find references, rename, nav-file checks, both previews and the faster preview start all arrived through antora-ls releases, without touching the extension.
Working within Zed's limits
Zed's extension API is deliberately small. Extensions can't add toolbar buttons and can't embed a browser, so both previews became code actions on the cmd-. menu:
- The live site preview opens in the system browser and follows the page being edited.
- The Markdown preview writes the current page as Markdown to a read-only file, which Zed's built-in Markdown preview then renders. It follows whichever page you work on and updates as you type.
For people who prefer a button, the README shows how to enable Zed's toolbar button for the code actions menu.
Getting it ready to publish
A release workflow checks a pushed tag against the versions in extension.toml and Cargo.toml, builds the extension for the wasm32-wasip2 target and creates a GitHub release. Zed builds extensions from source, so the release has no binaries; listing it in Zed's extension registry is a pull request to the zed-industries/extensions repository.
The extension is MIT licensed. The language server it runs is Apache-2.0 and derived from the AsciiDoc plugin for IntelliJ, which brings the story full circle in antora-intellij.