Editor support
whitehall lsp is the language server. The VS Code extension spawns it; any LSP
client can.
Usage
whitehall lsp The server speaks LSP over stdin and stdout and takes no flags of its own. Point any editor
with an LSP client at that command for .wh files.
What it answers
Diagnostics as you type
150ms after typing stops, the open file is checked with the same gate whitehall check runs: the file is parsed, every
lint rule runs — including the project-wide ones, imports, unknown components and $navigate against the route tree — and, when the lint is clean, the file is
transpiled. A parse or transpile error is a diagnostic at the line it names. The buffer is
read from memory; the rest of the project is read from disk and re-read on save.
<Colum> unknown-component … Did you mean `<Column>`?
class="text-lgg" unknown-class Hover, with receipts
On a @prop, a var or val, a store class, or a store
field (PlayerStore.isExpanded, from any file in the project): the declaration
with its type, then the receipt whitehall why prints
for it — what the compiler decided and why. The receipt is for the buffer as it is, unsaved
edits included.
Go to definition
On a component tag (<AlbumCard> goes to src/lib/components/AlbumCard.wh), anywhere on import $lib.x.Y, or on a name the project declares: the file, and the class or
function inside it when the name is one. A name declared in the open file (var, @prop, fun) goes to its declaration. Names resolve through the same
symbol table the import check uses, so a moved file is found where it now is.
Formatting
textDocument/formatting runs whitehall format's
formatter on the buffer, in-process. A file that does not parse is left as it is.
VS Code
The extension in editors/vscode-whitehall provides syntax highlighting and
starts whitehall lsp for everything that needs the compiler. Install it from
source:
cd editors/vscode-whitehall
pnpm install && pnpm build # type-checks, bundles, packages the .vsix
code --install-extension whitehall-0.1.0.vsix | Setting | Default | What it does |
|---|---|---|
whitehall.path | "whitehall" | The binary the extension runs lsp on |
The extension runs the whitehall on your PATH; point whitehall.path at target/debug/whitehall to use a checkout's build.
Format on save is on for .wh files through VS Code's own setting. To turn it
off:
"[whitehall]": { "editor.formatOnSave": false } PATH. Everything
past highlighting comes from the server, so an editor without the extension gets the same
diagnostics, hover, definitions and formatting from whitehall lsp.See Also
- whitehall check — the gate the diagnostics run
- whitehall why — the receipts hover shows
- whitehall format