lsp-asun is the Zig-based language server for ASUN. It also acts as the shared runtime for editor-facing utilities such as formatting, compression, and ASUN/JSON conversion.
It follows the current ASUN syntax: scalar type hints use @, and complex fields keep @{...} / @[...].
- Runs a standard Language Server Protocol server over stdio
- Publishes parser and semantic diagnostics
- Provides hover, completion, semantic tokens, and inlay hints
- Formats and compresses ASUN documents
- Converts ASUN to JSON and JSON back to ASUN
- Exposes a WASM build for browser or embedded integrations
The native server currently supports:
textDocument/didOpentextDocument/didChangetextDocument/didClosetextDocument/hovertextDocument/completiontextDocument/formattingtextDocument/semanticTokens/fulltextDocument/inlayHintworkspace/executeCommand
The custom commands used by the VS Code extension are:
asun.compressasun.toJSONasun.fromJSON
- Zig
0.16.0or newer
The minimum Zig version comes from build.zig.zon.
Build the native binary for your current platform:
cd lsp-asun
zig buildOutput:
zig-out/bin/lsp-asun
Build an optimized release binary:
zig build --release=safeCross-compile for another target:
zig build -Dtarget=x86_64-linux --release=safe
zig build -Dtarget=aarch64-macos --release=safeIf no transform flag is provided, the binary starts the LSP server over stdio.
./zig-out/bin/lsp-asunYou can also pass the compatibility flag explicitly:
./zig-out/bin/lsp-asun --stdioCheck the version:
./zig-out/bin/lsp-asun --versionThe same binary can be used as a filter that reads from stdin and writes to stdout.
Format:
printf '%s\n' '{name@str,age@int}:(Alice,30)' | ./zig-out/bin/lsp-asun --formatCompress:
printf '%s\n' '{name@str, age@int}:\n (Alice, 30)' | ./zig-out/bin/lsp-asun --compressASUN to JSON:
printf '%s\n' '{name@str,age@int}:(Alice,30)' | ./zig-out/bin/lsp-asun --to-jsonJSON to ASUN:
printf '%s\n' '{"name":"Alice","age":30}' | ./zig-out/bin/lsp-asun --from-jsonRun the unit and integration-style tests:
cd lsp-asun
zig build testBuild the WebAssembly artifact:
cd lsp-asun
zig build wasmExpected output:
zig-out/wasm/asun-lsp.wasm
The native executable is named lsp-asun, while the current WASM artifact is still named asun-lsp.wasm.
The WASM target exposes helpers for:
- validation
- formatting
- compression
- ASUN to JSON
- JSON to ASUN
- basic completion
The extension under ../plugin_vscode launches this binary over stdio. In practice, packaging usually works like this:
- Build
lsp-asun - Copy the binary into
plugin_vscode/server/ - Start it from the extension host with
-stdio
The extension also uses workspace/executeCommand to call:
asun.compressasun.toJSONasun.fromJSON
lsp-asun/
├── build.zig
├── build.zig.zon
├── src/
│ ├── main.zig
│ ├── server.zig
│ ├── features.zig
│ ├── analyzer.zig
│ ├── lexer.zig
│ ├── parser.zig
│ └── wasm.zig
└── tests/
└── lsp_test.zig
- The default transport is stdio.
- Diagnostics include both parse errors and semantic checks.
- This directory is the canonical place for the Zig LSP implementation; editor packaging should treat it as the source of the
lsp-asunbinary. - The current WASM output filename is
asun-lsp.wasm, which differs from the native executable name.