sqllens-language-server
A multi-dialect SQL language server built on sqllens,
the TypeScript SQL parser and static analyzer. The server is a thin Language Server
Protocol (LSP) adapter: it maps editor requests to the library's passes (parse → lower → resolveScopes → qualify → infer → symbols) and translates the results into
LSP shapes. It holds no analysis logic of its own: diagnostics, types, definitions,
output columns, tokens, completions, and signatures all come from the library.
Source-first and semantics-first: the server understands SQL statically, across ten
real dialects, without a database connection. Schema knowledge is optional and file-fed;
with it you get semantic diagnostics, typed hover, and schema-aware completion, and
without it the syntax tiers keep working.
Dialects: databricks, tsql, snowflake, bigquery, redshift, postgres,
duckdb, trino, sqlite, mysql.
Install and run
npm install -g sqllens-language-server
sqllens-language-server --stdio
The server speaks LSP over stdio (the --stdio flag is required). It is meant to be
launched by an editor / LSP client, not used interactively from a terminal.
sqllens-language-server --help is the one-screen map of what the binary can do:
Usage: sqllens-language-server <transport>
Transports (exactly one required):
--stdio JSON-RPC over stdin/stdout (the common choice)
--node-ipc Node child-process IPC (when forked from a Node host)
--socket=<port> connect to a TCP port the client is listening on
--pipe=<name> named pipe (Windows) / Unix domain socket
Options:
--help print this help and exit
--version print the version and exit
Configuration (discovered from the initialize workspace root, not passed as flags):
<workspace>/.sqllens.json project layer: glob-to-dialect rules, default dialect,
schema catalog, plugins
~/.sqllens.json user layer, merged under the project file
Environment:
SQLLENS_USER_CONFIG=<path> user-layer config location (default ~/.sqllens.json)
SQLLENS_NO_PLUGINS=1 disable plugin loading
SQLLENS_TRACE_SYNC=<file> append per-change document-sync traces (debug aid)
Features: diagnostics (push and pull), typed hover with lineage, completion,
signature help, go to definition, references, document symbols, semantic tokens,
code actions, folding, inlay hints, code lens, selection ranges.
Dialects: databricks, tsql, snowflake, bigquery, redshift, postgres, duckdb,
trino, sqlite, mysql.
Feature status
The server holds one session per open file (rebuilt on edit) and serves every feature
from that cached document. Every feature carries real source positions (no count-only
or point-only output), and the interactive features work on mid-edit / invalid input.
A SQL server needs only a subset of LSP's ~30 request types: some don't apply to
SQL (type hierarchy, document color, monikers), and a few are deferred (formatting,
project-wide navigation). Where the server stands today, feature by feature:
Language features
| Feature | Status |
|---|
| Completion (+ resolve) | ✅ |
| Hover | ✅ |
| Hover — nullability | ✅ ( — not null / — nullable suffix when provable) |
| Signature help | ✅ |
| Go to definition | ✅ |
| Find references | ✅ |
| Document highlight | ✅ |
| Document symbols | ✅ |
| Folding range | ✅ |
| Selection range | ✅ |
| Semantic tokens (full / range / delta) | ✅ all three |
| Inlay hints | ✅ (no resolve) |
| Code lens | ✅ (no resolve) |
| Go to declaration | ◻️ not yet |
| Go to type definition | ◻️ not yet |
| Go to implementation | ◻️ not yet — name → its defining query (view / model); needs the project model |
| Call hierarchy | ◻️ not yet — the CTE / view / model dependency graph |
| Document link | ◻️ not yet |
| Linked editing range | ◻️ not yet — live alias / name sync-edit |
| Code action (quick fixes) | ✅ for .sqllens.json (change-dialect fixes) · ◻️ SQL quick fixes next phase |
| Rename (+ prepare) | ◻️ next phase |
| Formatting / range / on-type | ◻️ deferred (external formatter) |
| Inline values | ◻️ debugger surface |
| Type hierarchy | — n/a — SQL has no type-inheritance relation |
| Document color | — n/a — no color literals |
| Moniker | — n/a — LSIF / cross-repo indexing concern |
Diagnostics & document sync
| Feature | Status |
|---|
Diagnostics — push (publishDiagnostics) | ✅ |
| Diagnostics — call signature (arity / argument type) | ✅ (curated tables; never-wrong, per-dialect coercion) |
| Diagnostics — pull (document) | ✅ |
| Diagnostics — pull (workspace) | ◻️ not yet |
| Text sync — open / change / close | ✅ (full-document) |
| Incremental sync | ◻️ full-document only (fine at SQL file sizes) |
Save notifications (didSave / willSave) | ◻️ not yet |
| Notebook document sync | ◻️ not yet |
Workspace features