Gleam-authored Zed extension (Gleam → Wasm guest) for Gleam LSP + highlighting
0

Configure Feed

Select the types of activity you want to include in your feed.

Nix 36.3%
Tree-sitter Query 24.1%
Rust 20.9%
Gleam 9.7%
Shell 9.1%
1 1 0

Clone this repository

https://git.vm.fail/nandi.uk/zed-gleam-native https://git.vm.fail/did:plc:npzwwr6fhagvxeeo42p2nxo3
ssh://git@knot1.tangled.sh:2222/nandi.uk/zed-gleam-native ssh://git@knot1.tangled.sh:2222/did:plc:npzwwr6fhagvxeeo42p2nxo3

For self-hosted knots, clone URLs may differ based on your setup.


README.md

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:

  1. Runs gleam export zed-extension (build.rs)
  2. Installs that component as the crate’s .wasm output (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#

  1. Ensure GLEAM is set in the environment Zed inherits, or keep a sibling ~/code/gleam build at target/debug/gleam.

  2. Extensions → Install Dev Extension…

    /home/nandi/code/zed-gleam-native
    
  3. Open a *.gleam file — the guest starts gleam lsp.

LSP binary resolution#

  1. worktree.which("gleam") (PATH)
  2. Fallback: bare gleam command
{
  "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).