An extension for Zed that adds Roc language support:
- syntax highlighting through treesitter and
- type tooltips, error marker, completion ... through the roc language server
- Install Roc from the roc-lang website
- Ensure the
rocbinary is in your PATH - Install Zed from the Zed website
- Install the Zed extension WebAssembly target for development:
rustup target add wasm32-wasip2
- Website: roc-lang.org
- Tree Sitter: tree-sitter-roc
- Language Server: This extension uses the new experimental LSP integrated into the
rocCLI viaroc experimental-lsp.
- Open Zed's command palette (Cmd+Shift+P / Ctrl+Shift+P)
- Run "zed: install dev extension"
- Select this repository folder
- Click "Rebuild" if prompted
Note: The version shown in Zed's Extensions panel may display the marketplace version even when the dev extension is active. This is a Zed caching behavior when the extension ID matches a marketplace extension.
Check Zed's logs (Command palette → "zed: open log file") and look for:
compiling Rust extension /path/to/your/zed-roc
If the path points to your local repository (not ~/Library/Application Support/Zed/extensions/installed/roc), the dev extension is active.
extension.toml- Extension manifest (id, version, grammar source, language config)languages/roc/config.toml- Language configuration (file extensions, comments, brackets)languages/roc/*.scm- Tree-sitter queries (highlights, indents, etc.)src/lib.rs- Rust extension entry point that launchesroc experimental-lsp --stdio
cargo fmt -- --check
cargo clippy --all-targets -- -D warnings
cargo test
cargo build --target wasm32-wasip2Zed fetches the grammar from the repository and commit in extension.toml. The local grammars/roc/ directory is ignored and only used as a working checkout when syncing query files.
To update:
- Update the commit hash in
extension.tomlunder[grammars.roc] - Sync query files:
just sync-queries
- In Zed, click "Rebuild" on the extension
Extension not detecting .roc files:
- Check Zed logs for errors (Command palette → "zed: open log file")
- Ensure
languages = ["languages/roc"]is inextension.toml
Conflict with marketplace version:
- Uninstall the marketplace Roc extension first
- If uninstall doesn't work, quit Zed and manually edit the extensions index.json to remove "roc" entries
- Zed stores extensions in:
- macOS:
~/Library/Application Support/Zed/extensions/ - Linux:
~/.local/share/zed/extensions/
- macOS:
Grammar compilation errors:
- Check that
[grammars.roc]inextension.tomlpoints to a valid repository and commit - Remove any cached
grammars/roc.wasmorextension.wasm, then rebuild the extension
# Sync query files from grammar to languages
just sync-queries
# Clean build artifacts
just clean
# Check Zed logs (macOS)
tail -f ~/Library/Logs/Zed/Zed.log | grep -i rocThe just recipes are optional conveniences. The validation commands above only require Rust.
