All work

LSP-syntect

A language server for writing .sublime-syntax files.

Source on GitLab Sublime Text · MPL-2.0 · v0.8.0
A .sublime-syntax file with a squiggly-underlined undefined context reference on a push key, and an LSP hover popup from syntect-server reading Undefined context notes-detail with Definition and References links.

A language server for .sublime-syntax grammar files: it flags missing contexts, invalid regexes, and undefined references while you write, and supports navigation between contexts. I do all my work in Sublime Text, which means I've had to debug tricky issues by looking at the source code for LSP servers more than once.

The server is a small Rust binary built on the syntect crate. The plugin downloads a prebuilt binary for Linux or Windows (x64), so you do not need a Rust toolchain there; there is no macOS build yet.

A .sublime-syntax grammar file is checked over the Language Server Protocol by syntect-server, a small Rust binary built on the syntect crate; the plugin downloads a prebuilt syntect-server release for the current platform, so no Rust toolchain is required, and the server reports diagnostics such as a missing main context, invalid regexes, and undefined references. syntax file LSP syntect-server diagnostics release no toolchain
Sublime Text talks to syntect-server, a Rust binary, over stdio with Content-Length framed JSON-RPC. On didOpen and didChange the server re-parses the whole file in four passes: saphyr-parser walks the YAML for symbols and source spans, a regex scan finds double-brace variable references, the syntect crate loads the syntax to validate it and fill in variable values, and a cross-reference check flags undefined names. All four passes write into one DocumentIndex of variables, contexts, labels, three kinds of reference, and diagnostics. Diagnostics are pushed to Sublime (amber); documentSymbol, definition, references, hover, completion, and inlayHint are answered from the index on request (cyan). syntect-server Rust, 1,254 lines in 5 files parser.rs 601 index.rs 161 server.rs 437 Sublime Text plugin.py 532 stdio JSON-RPC 1 saphyr-parser symbols and source spans 2 regex scan {{name}} references 3 syntect crate validate, enrich values 4 cross-reference check undefined names DocumentIndex variables contexts labels variable_refs context_refs label_refs diagnostics publishDiagnostics documentSymbol definition references hover completion inlayHint diagnostics: error for invalid YAML or regex; warning for missing main, undefined variable, context, label input: the full text on didOpen and didChange; diagnostics are pushed, never pulled, and cleared on didClose undefined variable and context checks skip a file that extends another crates: syntect 5.3, saphyr-parser 0.0.6, regex 1, serde_json 1; messages use Content-Length framing