Skip to content

feat(language-server): standalone Malloy LSP with render-tag diagnostics#2816

Draft
jswir wants to merge 4 commits into
malloydata:mainfrom
jswir:feat/malloy-lsp
Draft

feat(language-server): standalone Malloy LSP with render-tag diagnostics#2816
jswir wants to merge 4 commits into
malloydata:mainfrom
jswir:feat/malloy-lsp

Conversation

@jswir
Copy link
Copy Markdown
Contributor

@jswir jswir commented May 19, 2026

Summary

  • Add @malloydata/malloy-language-server — a standalone LSP-over-stdio implementation for .malloy, .malloysql, and .malloynb files. Provides diagnostics, document symbols, code lenses, completions, hover, go-to-definition, and code actions.
  • Ship a CLI binary (malloy-language-server --stdio) and a Claude Code plugin scaffold under claude-code-plugin/ so LSP-capable editors (Neovim, Emacs, Helix, Claude Code, etc.) can spawn the server directly.
  • Wire @malloydata/render-validator into the diagnostic pipeline so renderer tag mistakes (e.g. # currency on a string field) surface in the editor as the user types instead of only at preview time. Render-validator runs the renderer's own validation against the compiled result without executing the query or needing a DOM. Diagnostics carry code: render-tag so they're distinguishable from compile errors.

Test plan

  • npm run build builds the new package cleanly against current main
  • npx eslint 'packages/malloy-language-server/src/**/*.ts' passes (0 errors; pre-existing no-console warnings only)
  • All new files carry the standard copyright header
  • Stdio smoke test: initializeinitializedworkspace/didChangeConfigurationtextDocument/didOpen round-trips with capabilities and emits publishDiagnostics
  • Render-tag diagnostic verified end-to-end with the smoke test:
    query: q is duckdb.sql("SELECT 'hello' as val") -> {
      select:
        # currency
        val
    }
    
    [sev=Error] code=render-tag Tag 'currency' on field 'val' requires a numeric field, but field is string
  • Reviewer: exercise the server in an LSP client (Neovim, Helix, VS Code generic-LSP, Claude Code)

jswir added 2 commits May 18, 2026 22:55
New @malloydata/malloy-language-server package implementing LSP over
stdio for .malloy, .malloysql, and .malloynb files. Provides:

- Diagnostics (syntax + semantic, with notebook cell mapping)
- Document symbols
- Code lenses (Run / Show SQL / Preview)
- Context-aware completions and hover docs
- Go-to-definition for sources, fields, and imports
- Code actions

Ships a CLI binary (`malloy-language-server --stdio`) and a Claude Code
plugin scaffold under `claude-code-plugin/` so LSP-capable editors can
spawn the server directly.

Signed-off-by: James Swirhun <james@credibledata.com>
…der-validator

Validate renderer tag usage on every named and unnamed query in the
model on each diagnostic pass. The render-validator runs the renderer's
own validation against the compiled query result without executing the
query or needing a DOM, so errors like '# currency on a string field'
appear directly in the editor as the user types instead of only at
preview time.

Renderer log messages already carry source url+range via the tag's
DocumentLocation; when absent the diagnostic falls back to the query's
range. Diagnostics are tagged with code 'render-tag' so users can
distinguish them from compile errors.

Signed-off-by: James Swirhun <james@credibledata.com>
@jswir jswir marked this pull request as draft May 19, 2026 05:44
jswir added 2 commits May 19, 2026 00:55
I, James Swirhun <james@credibledata.com>, hereby add my Signed-off-by to this commit: 9c3de00

Signed-off-by: James Swirhun <james@credibledata.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant