//// Zed extension written in Gleam. //// //// `gleam export zed-extension` packages a full `zed:extension` world //// component. The guest shell implements every world export; this module //// documents the intended `language_server_command` callback that the //// compiler wires into the CABI layer. //// //// Resolution order for the glint binary: //// 1. `worktree.which("glint")` (PATH) //// 2. Fallback: `/home/nandi/code/glint/result/bin/glint` /// Opaque worktree handle from the Zed host (resource `i32`). pub type Worktree /// Process command returned to Zed to start a language server. pub type Command { Command(command: String, args: List(String), env: List(#(String, String))) } /// Look up a binary on the worktree `$PATH`. /// /// Implemented by the guest shell via `[method]worktree.which`. @external(wasm, "$root", "[method]worktree.which") pub fn which(worktree: Worktree, binary_name: String) -> Result(String, Nil) /// Extension entry: no-op init. pub fn init() -> Nil { Nil } /// Return the command used to start the glint language server. pub fn language_server_command( _language_server_id: String, worktree: Worktree, ) -> Result(Command, String) { case which(worktree, "glint") { Ok(path) -> Ok(Command(path, ["lsp"], [])) // Default local checkout when `glint` is not on `$PATH`. Error(_) -> Ok(Command("/home/nandi/code/glint/result/bin/glint", ["lsp"], [])) } }