Wado

WEP: LSP Architecture

Context

wado-vscode currently provides only TextMate syntax highlighting. Wado needs a Language Server Protocol (LSP) integration so editors can surface diagnostics, hover, go-to-definition, references, and semantic tokens on .wado files. The same language server must also power the browser-based playground on the official Wado site.

Personas with opposing needs

What exists today

The earlier wado-lsp/README.md proposed a Wasm-only, subprocess-less architecture with a handwritten C ABI bridge. That proposal is withdrawn by this WEP.

Constraints

Build feasibility verification

To establish feasibility before this WEP was written, the following was verified against the current tree (2026-04-18):

Prerequisites to confirm at implementation time

Considered alternatives

Decision

Single LSP server implementation, two build targets

wado-lsp owns the entire LSP server: the Engine, the stdio JSON-RPC transport, the request dispatcher, the LSP wire types, and a FilesystemCompilerHost. A new [[bin]] wado-lsp is added. The binary builds for both native and wasm32-wasip2:

Both targets speak the same LSP JSON-RPC wire protocol over stdio.

Crate layout

wado-lsp/
├── src/
│   ├── lib.rs                # Engine (existing)
│   ├── diagnostics.rs, ...   # (existing)
│   ├── host.rs               # FilesystemCompilerHost (moved from wado-cli)
│   └── server/
│       ├── mod.rs            # pub async fn run_stdio()
│       ├── transport.rs      # Content-Length header + JSON-RPC framing
│       ├── dispatch.rs       # LSP method -> Engine routing
│       └── rpc.rs            # LSP wire types
└── src/bin/
    └── wado-lsp.rs           # #[tokio::main(flavor = "current_thread")] run_stdio()

The "protocol-agnostic" framing in the current wado-lsp/README.md is removed. wado-lsp is the LSP package; its library surface exposes a typed Engine that other consumers may reuse, but its primary deliverable is the LSP server binary.

No Cargo features gate the server. All dependencies (tokio, serde_json) are unconditional. wado-compiler dominates build time, so splitting the server behind a feature flag would not meaningfully change the Engine-only consumption profile.

wado-cli is a thin client

wado-cli mcp and wado-cli query are out of scope

The MCP server and the one-shot diagnostics CLI stay inside wado-cli. Both are native-only tools; neither currently has a compelling Wasm use case. A future WEP may revisit their placement. If that happens, it should follow the same pattern as this WEP: move the server implementation into a dedicated crate that builds for both native and wasm32-wasip2, and keep wado-cli as a thin dispatcher.

VS Code extension

wado-vscode gains an LSP client built on the official vscode-languageclient package. The client's ServerOptions callback has two branches:

  1. If wado.serverPath is set in settings, spawn that executable as a native subprocess with stdio piped to LanguageClient.
  2. Otherwise, launch the bundled wado-lsp.wasm via @vscode/wasm-wasi-core (or @vscode/wasm-component-model, depending on prerequisite validation). The Wasm host exposes the process as stdio streams; LanguageClient drives them identically to the native case.

Settings contributed by the extension:

Commands:

A vscode.workspace.createFileSystemWatcher on the bundled wado-lsp.wasm path triggers client.restart() automatically when the file changes, so a rebuild on disk reloads the running LSP with no user action.

Compiler-developer inner loop

Two complementary paths share the same server implementation:

Both workflows use the exact same server implementation, so observed behavior does not diverge between paths.

Playground compatibility

This WEP does not design the browser playground integration. It requires only that the produced wado-lsp.wasm remain compatible with a generic browser-worker environment: no VS Code-specific imports leak into the Wasm module. A follow-up WEP will design the JS/TS host and transport (likely MessagePort-based JSON-RPC) for the public site.

Distribution

Consequences

Benefits

Trade-offs

Breaking changes

Rollout

Implementation notes

See Also