Skip to main content

Module lsp

Module lsp 

Source
Expand description

The Language Server Protocol surface.

Diagnostics, published on open and on save. Not on every keystroke: a check reads files from disk, and the buffer an editor holds mid-edit is not on disk yet. Publishing against stale bytes would put squiggles under the wrong characters, which is worse than a short delay — §12 already says the warm cache is what makes one-shot fast, and the same cache makes a save-triggered re-check fast enough to feel immediate.

§Positions

LSP counts lines and characters from zero. lanekeep counts from one. Every diagnostic crosses that boundary, and getting it wrong shifts every squiggle up a line and left a column — visible, but easy to mistake for a rule reporting the wrong node. to_range is the one place the conversion happens, and it is tested at line and column 1 where the subtraction would underflow.

Functions§

by_file
Group violations by the file they belong to, as absolute paths.
capabilities
What the server tells the client it can do.
path_from_uri
The path a file:// URI refers to.
to_diagnostic
Convert a violation into an LSP diagnostic.
to_range
Convert a violation’s one-based position into LSP’s zero-based range.
uri_from_path
The file:// URI for a path.