OxL for Visual Studio Code
Language support for OxL (docs/spec/oxl-standard.md): syntax highlighting, and, through the language server
oxl lsp, diagnostics (with links to the diagnostic pages), hover, go to definition / type definition, find references,
rename (across the packages of a workspace and through rpc), document outline, workspace symbols, completion, signature
help, semantic highlighting (contextual keywords included), inlay hints (inferred types, chain errors, effects, where a
pipeline step runs, call markers "in process" / "over network → role" / "scatter-gather"), the rpc hover (callers,
policies, schema version, attributes with their final values), quick fixes and refactorings (handle all errors of a chain,
extract constant, add a policy, generate a mock, move a pipeline step to another role) and formatting (document,
selection, on type).
The extension is a thin client. Everything semantic is done by the compiler's own front end, so what the editor shows is
what oxl check reports. See docs/lsp.md in the repository for the protocol surface.
Requirements#
- An
oxlexecutable (build it with CMake, see the top-leveldocs/HANDOFF.md). It is found inPATH, or set theoxl.pathsetting to its absolute path (${workspaceFolder}and~are expanded).
Settings#
| Setting | Default | Meaning |
|---|---|---|
oxl.path | oxl | The compiler executable that runs oxl lsp. |
oxl.serverArgs | [] | Extra arguments for oxl lsp. |
oxl.debounceMs | 150 | Quiet time after the last edit before the package is analysed again. |
oxl.stdDir | empty | Standard library sources (OXL_STD_DIR); empty = the one oxl was built with. |
oxl.diagnosticsDocs | empty | Base URI of the diagnostic pages; empty = docs/diagnostics of the source tree. |
oxl.inlayHints.types | true | Inlay hints: inferred types of let bindings without an annotation. |
oxl.inlayHints.chainErrors | true | Inlay hints: the errors each link of a -> chain can produce. |
oxl.inlayHints.effects | true | Inlay hints: inferred effects of functions without a written effect list. |
oxl.inlayHints.pipelineRoles | true | Inlay hints: where a pipeline step without on role runs. |
oxl.inlayHints.callMarkers | true | Inlay hints: in process / over network / scatter-gather and the target role at calls. |
oxl.trace.server | off | messages / verbose logs the protocol traffic to the "OxL Language Server" output. |
The inlay hint settings take effect without a restart. The extension turns semantic highlighting and editor.formatOnSave on for OxL files (the formatter is canonical, oxl fmt gives the same
result); editor.formatOnType additionally reformats an item when } is typed.
Commands: OxL: Restart Language Server, OxL: Show Language Server Log.
Packages and single files#
A file below the src/ directory of a directory with an oxl.toml is analysed together with its package (all modules,
unsaved buffers of the other open files included). Any other .oxl file is analysed on its own. Standard library
symbols resolve exactly as in the compiler.
Building and packaging#
cd tools/vscode
npm install # downloads vscode-languageclient and the build tools into node_modules (not committed)
npm run compile # TypeScript -> out/extension.js
npm test # compile + manifest/grammar checks + TextMate tokenization tests (no VS Code needed)
npx vsce package --allow-missing-repository --skip-license # produces oxl-lang-0.1.0.vsix
code --install-extension oxl-lang-0.1.0.vsixTo try the extension without packaging, open tools/vscode in VS Code and press F5 (Extension Development Host),
then set oxl.path to build/tools/oxl/oxl in the new window.
If vsce cannot be installed (no network), the extension can still be used from source: copy or symlink this directory
to ~/.vscode/extensions/oxwaldlink.oxl-lang-0.1.0 after npm install --omit=dev && npm run compile.
Verifying in a live VS Code (manual checklist)#
Automated checks (npm test, npm run smoke) cover the manifest, the grammar, the compiled entry point, the contents of the
.vsix, activate() against a stub of the vscode API and the real oxl lsp --stdio handshake. They cannot show the editor
itself, so do this once per release in a real VS Code >= 1.75 (the machine needs a built oxl, see docs/HANDOFF.md):
- Build and install the package:
sh cd tools/vscode npm ci || npm install npm test && npm run smoke npx vsce package --allow-missing-repository --skip-license # -> oxl-lang-0.1.0.vsix code --install-extension oxl-lang-0.1.0.vsix --force(npm run packagedoes the lastvscestep; the smoke test builds a throw-away.vsixitself when no path is given.) - Open the repository's
examples/shopfolder (code examples/shop). In Settings (Ctrl+,) set OxL: Path to the absolute path ofbuild/tools/oxl/oxl(or put it inPATH). Reload the window. - Open
examples/shop/src/cart/cart.oxl(any.oxlfile). Expect, within a second: the status bar shows the language OxL; keywords, durations (30s), string interpolation and attributes are coloured; View > Output > OxL Language Server shows the server starting and no error. - Diagnostics: type
let x: i32 = "a"inside a function. A red squiggle appears with the code (for exampletype-mismatch) as a link to its page underdocs/diagnostics; the Problems panel lists it. Undo: it disappears. - Hover a function call (signature and doc comment),
F12on a call (jumps to the declaration, also intostd/),Shift+F12(references),F2(rename across the package),Ctrl+Spaceafter a.(members),Ctrl+Shift+Spaceinside a call (signature help),Ctrl+Shift+O(outline lists the declarations). - Formatting: mis-indent a block and save. The file is reformatted (format on save is on for OxL);
Shift+Alt+Fdoes the same.build/tools/oxl/oxl fmt --check examplesmust agree with what the editor produced. - Commands (
Ctrl+Shift+P): OxL: Restart Language Server (the Output panel shows the restart, diagnostics return) and OxL: Show Language Server Log. Set OxL: Path to a wrong path and reload: a messageThe OxL executable ... does not existwith an Open Settings button appears, and nothing crashes. - Debugging (needs
lldb-dap-18): openexamples/v1_hello.oxl(or any single file withfn main()), put a breakpoint, pressF5and pick OxL. The program is built with debug info, stops at the breakpoint, andVariablesshowsstr,ListandMapvalues through the pretty-printers. (Known gaps: no parked-task stacks, seedocs/debugger.md.) - Uninstall:
code --uninstall-extension oxwaldlink.oxl-lang.
Record the VS Code version and the result of each step in the release notes. If a step fails, Output > OxL Language Server with
OxL > Trace: Server set to verbose has the protocol traffic.
Files#
| File | What |
|---|---|
src/extension.ts | Starts oxl lsp with vscode-languageclient, settings, restart command, file watchers. |
syntaxes/oxl.tmLanguage.json | TextMate grammar (keywords, literals incl. durations / sizes / dates, string interpolation, attributes, effects, doc comments). |
language-configuration.json | Comments, brackets, auto-closing, doc-comment continuation, indentation. |
scripts/check-grammar.js, scripts/tokenize-test.js, scripts/extension-test.js | Tests run by npm test. |
scripts/smoke-test.js | npm run smoke: checks the .vsix, runs activate() against a stub and handshakes with the real oxl lsp (ctest vscode_smoke). |
Source: tools/vscode/README.md