Zed language support for go-zero goctl .api files, modeled after the implemented feature set in zeromicro/goctl-vscode.
.apifile association with thegoctllanguage.- Tree-sitter syntax highlighting for goctl API files.
- Comment, bracket, auto-closing, and surrounding-pair editor configuration.
- Snippets for imports,
info,service,type, handlers, field tags, annotations, and common HTTP routes. - Formatting through the installed
goctlCLI. - Definition, reference, and document-symbol support through a lightweight LSP.
- Direct
import "relative.api"type-definition lookup for route request/response types. - Route request/response type names are highlighted only when the type resolves in the active file or a directly imported
.apifile.
-
Install
goctland make sure it is available onPATH:goctl --version
-
Install Node.js. The extension uses Node to run the lightweight language server when a native
goctl-api-lspexecutable is not available. -
Install this repository as a Zed dev extension:
- Open the Zed command palette.
- Run
zed: extensions. - Choose
Install Dev Extension. - Select this repository directory.
-
Open
fixtures/sample.apior any.apifile.
Formatting uses:
goctl api format --stdinIf formatting fails, check that goctl is installed, executable, and visible to the environment used by Zed. You can set GOCTL_BIN before launching Zed to point the language server at a specific binary path.
For public releases, the extension does not launch a language server bundled inside the extension package. At startup it resolves the server in this order:
- Use
goctl-api-lspfrom the user'sPATHwhen available. - Use a previously downloaded
goctl-api-lsp.mjsfrom the Zed extension work directory. - Use the repository-local
server/goctl-api-lsp.mjswhen running as a dev extension. - Otherwise, download
goctl-api-lsp.mjsfrom the latest GitHub Release forcaichuanwang/goctl-zedinto the Zed extension work directory and run it with Node.
For local development before a GitHub Release exists, installing this repository as a dev extension uses server/goctl-api-lsp.mjs directly. You can also force the PATH branch:
mkdir -p .local/bin
ln -sf "$PWD/server/goctl-api-lsp.mjs" .local/bin/goctl-api-lsp
PATH="$PWD/.local/bin:$PATH" zed .For public releases, attach server/goctl-api-lsp.mjs to the GitHub Release as goctl-api-lsp.mjs.
The extension registers snippets/goctl.json. Useful triggers include:
iminfoservicetype/tyshandler/@handler@doc/@serverjson/path/formget/post/put/delete
- Syntax diagnostics are not implemented.
- Cross-file references are not implemented.
- Recursive import graph resolution is not implemented; only direct relative
.apiimports are followed for type definitions.
Run local checks:
npm test
cargo check
openspec validate implement-goctl-zed-plugin --strictTo build the extension for Zed's WebAssembly target:
rustup target add wasm32-wasip2
cargo build --target wasm32-wasip2