Zed Gleam (native)#
Gleam-authored Zed extension for Gleam: tree-sitter highlighting and the Gleam language server.
This is a port of gleam-lang/zed-gleam
from Rust/zed_extension_api to Gleam → Wasm via
our Gleam Wasm compiler (gleam export zed-extension).
Source of truth: src/zed_gleam.gleam
Artifact: extension.wasm (Zed zed:extension component, API 0.7.0)
Build#
Zed’s Install Dev Extension only knows how to run:
cargo build --target wasm32-wasip2
So this package includes a tiny cargo build driver that does not implement the extension. It only:
- Runs
gleam export zed-extension(build.rs) - Installs that component as the crate’s
.wasmoutput (scripts/gleam-wasm-linker)
src/lib.rs is an empty compile stub required by cargo; its code is discarded.
Prerequisites#
# Wasm-capable Gleam (our fork)
# https://tangled.org/nandi.uk/gleam — branch wasm
git clone https://tangled.org/nandi.uk/gleam
cd gleam && git checkout wasm
cargo build -p gleam
export GLEAM="$PWD/target/debug/gleam"
# Cargo target so `cargo build --target wasm32-wasip2` can run
rustup target add wasm32-wasip2
build.rs also auto-finds ../gleam/target/debug/gleam when this repo and
gleam are siblings (e.g. under ~/code/).
Build the extension#
cd /home/nandi/code/zed-gleam-native
export GLEAM=/path/to/gleam/target/debug/gleam # if not auto-found
cargo build --release --target wasm32-wasip2
# → target/wasm32-wasip2/release/zed_gleam.wasm (from Gleam)
Or call Gleam directly:
$GLEAM export zed-extension
# → extension.wasm
Install in Zed#
-
Ensure
GLEAMis set in the environment Zed inherits, or keep a sibling~/code/gleambuild attarget/debug/gleam. -
Extensions → Install Dev Extension… →
/home/nandi/code/zed-gleam-native -
Open a
*.gleamfile — the guest startsgleam lsp.
LSP binary resolution#
worktree.which("gleam")(PATH)- Fallback: bare
gleamcommand
{
"lsp": {
"gleam": {
"binary": {
"path": "/path/to/gleam",
"arguments": ["lsp"]
}
}
}
}
Layout#
| Path | Role |
|---|---|
src/zed_gleam.gleam |
Extension (Gleam) |
build.rs |
Driver: gleam export zed-extension |
scripts/gleam-wasm-linker |
Driver: cargo output = Gleam component |
src/lib.rs |
Empty stub for cargo only |
extension.toml |
Zed manifest (kind = "Rust" is required by Zed’s schema) |
languages/gleam/ |
Tree-sitter queries + language config |
extension.wasm |
Built component |
Status vs Rust zed-gleam#
| Feature | Rust (zed-gleam) | This port |
|---|---|---|
| Syntax / grammar | yes | yes (same queries) |
gleam lsp command |
yes | yes — Gleam body lifted through CABI |
| Download Gleam from GitHub | yes | not yet (PATH only) |
| Completion code labels | yes | stub (compiler default) |
/gleam-project slash command |
yes | declared; guest stub |
Compiler docs: https://tangled.org/nandi.uk/gleam (docs/compiler/wasm-zed-extensions.md).