Gleam-inspired typed configuration language (POC)
0

Configure Feed

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

glint / editors / zed / src / zed_glint.gleam
1.4 kB 42 lines
1//// Zed extension written in Gleam. 2//// 3//// `gleam export zed-extension` packages a full `zed:extension` world 4//// component. The guest shell implements every world export; this module 5//// documents the intended `language_server_command` callback that the 6//// compiler wires into the CABI layer. 7//// 8//// Resolution order for the glint binary: 9//// 1. `worktree.which("glint")` (PATH) 10//// 2. Fallback: `/home/nandi/code/glint/result/bin/glint` 11 12/// Opaque worktree handle from the Zed host (resource `i32`). 13pub type Worktree 14 15/// Process command returned to Zed to start a language server. 16pub type Command { 17 Command(command: String, args: List(String), env: List(#(String, String))) 18} 19 20/// Look up a binary on the worktree `$PATH`. 21/// 22/// Implemented by the guest shell via `[method]worktree.which`. 23@external(wasm, "$root", "[method]worktree.which") 24pub fn which(worktree: Worktree, binary_name: String) -> Result(String, Nil) 25 26/// Extension entry: no-op init. 27pub fn init() -> Nil { 28 Nil 29} 30 31/// Return the command used to start the glint language server. 32pub fn language_server_command( 33 _language_server_id: String, 34 worktree: Worktree, 35) -> Result(Command, String) { 36 case which(worktree, "glint") { 37 Ok(path) -> Ok(Command(path, ["lsp"], [])) 38 // Default local checkout when `glint` is not on `$PATH`. 39 Error(_) -> 40 Ok(Command("/home/nandi/code/glint/result/bin/glint", ["lsp"], [])) 41 } 42}