Official Roc language support, powered by the language server built into the roc compiler.
- Syntax highlighting, including Roc code blocks in doc comments and Markdown files
- Diagnostics as you type
- Formatting (format on save is on by default for Roc files)
- Hover with inferred types, go to definition, find references, document highlights
- Completion, rename, document symbols, folding and selection ranges
- Inlay hints for inferred types
- Code action: annotate a binding with its inferred type
- Semantic highlighting
- Roc: Run File and Roc: Test File from the editor title bar, and a
roctask type
Thanks to Luke Boswell, whose roc-vscode showed how to test the packaged VSIX, and inspired the language feature, editing and server lifecycle tests here.
Checking Roc code can download packages and run compile-time Roc code, so the language server only runs in trusted workspaces. In restricted mode the extension still highlights, formats (with roc fmt, which only parses) and folds. Trusting the workspace starts the language server.
In restricted mode, roc.path and roc.server.args are only read from your user settings, so a repository can't choose which program runs.
| Setting | Default | Description |
|---|---|---|
roc.path |
"" |
Path to the roc executable. ~ and ${userHome} are expanded. |
roc.server.args |
["experimental-lsp"] |
Arguments that start the language server. |
roc.server.debugFlags |
[] |
Any of --debug-transport, --debug-build, --debug-syntax, --debug-server. The log file path appears in the Roc output. Transport logs contain your source code. |
roc.nightly.checkForUpdates |
true |
Weekly update check for the nightly installed by the extension. |
roc.trace.server |
"off" |
Log language server messages to the Roc output. |
npm ci # install pinned dependencies (install scripts are disabled in .npmrc)
npm run check # typecheck
npm test # unit tests and grammar snapshot tests
npm run test:nightly # install the nightly pinned in test/roc-nightly.txt into .vscode-test/roc with the extension's installer
ROC_PATH=/path/to/roc npm run test:integration # package, install and test the VSIX in a real VS Code
npm run package # build roc-<version>.vsixThe integration tests install the packaged VSIX into a fresh VS Code profile, so packaging mistakes show up. They run once in a trusted and once in a restricted workspace, and check language features, editing, and restarting and stopping the language server. ROC_VSIX tests an existing VSIX instead of packaging one, VSCODE_VERSION picks the VS Code build, and ROC_TEST_GREP runs only the tests whose name contains it. CI also checks the VSIX contents against test/vsix-files.txt.
Press F5 to try changes in a new VS Code window.
The TextMate grammar lives in syntaxes/roc.tmLanguage.json. After changing it, run npm run test:grammar -- --update and review the snapshot diff in test/grammar/fixtures/.
Dependencies are deliberately few: vscode-languageclient at runtime, and Microsoft's or esbuild's own tooling for development. New versions are only adopted once they have been published for at least two weeks.