Glint for Zed#
Gleam-authored Zed extension for Glint: tree-sitter highlighting (via tree-sitter-gleam) and the glint language server.
Source of truth: src/zed_glint.gleam
Artifact: extension.wasm (Zed zed:extension component, API 0.7.0)
Nix (recommended install)#
From the glint repo (uses the gleam wasm fork as a flake input):
cd /home/nandi/code/glint
# optional: use a local gleam checkout
# nix build .#zed-extension --override-input gleam path:../gleam
nix build .#zed-extension
# → ./result/{extension.toml,extension.wasm,languages/…}
nix run .#install-zed-extension -- ~/glint-zed-dev
# then Zed → Extensions → Install Dev Extension → ~/glint-zed-dev
nix develop sets GLEAM to the wasm-capable compiler for the cargo build
driver in this directory.
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#
# Glint LSP binary
cd /home/nandi/code/glint && nix build # → result/bin/glint
# 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 glint and
gleam are siblings (e.g. under ~/code/).
Build the extension#
cd /home/nandi/code/glint/editors/zed
export GLEAM=/path/to/gleam/target/debug/gleam # if not auto-found
cargo build --release --target wasm32-wasip2
# → target/wasm32-wasip2/release/zed_glint.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/glint/editors/zed -
Open a
*.glintfile — the guest startsglint lsp.
LSP binary resolution#
lsp.glint.binaryin Zed settingsglinton$PATH- Fallback:
/home/nandi/code/glint/result/bin/glint
{
"lsp": {
"glint": {
"binary": {
"path": "/home/nandi/code/glint/result/bin/glint",
"arguments": ["lsp"]
}
}
}
}
Layout#
| Path | Role |
|---|---|
src/zed_glint.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/glint/ |
Tree-sitter queries + language config |
extension.wasm |
Built component |
Grammar id is gleam (exports tree_sitter_gleam). Language name / path
suffix stay Glint / *.glint.
Compiler docs: https://tangled.org/nandi.uk/gleam (docs/compiler/wasm-zed-extensions.md).