Cirru language support for Zed.
This first implementation focuses on syntax highlighting and bracket matching.
It maps the lexical categories from parser.rs into a lightweight Tree-sitter
grammar that highlights:
- line comments starting with
;or;; - string literals and escape sequences
- special Cirru operators
$and, - parentheses
- common keyword, boolean, number, and keyword-like token patterns
- Generate the parser in
grammars/tree-sitter-cirru/. - Install this repository as a Zed dev extension.
- Open a
.cirrufile and confirm highlighting.
The grammar is currently loaded from a local file:// URL in extension.toml so
it can be tested immediately on this machine. Before publishing, switch that to
the real Git repository URL and a fixed commit hash.
- This grammar is intentionally lexical-first. It does not yet model Cirru's
indentation tree like
parser.rsdoes. - Highlighting is already useful, but structural features such as indentation, outline, and exact top-level form detection still need a second iteration.
- Once the basic grammar settles, the next step is likely an external scanner for indentation-sensitive parsing.
If you clone this repo to a new machine and install it as a dev extension, there are a few things to watch out for:
extension.toml uses a file:// URL to point Zed at the grammar source. Zed treats
this as a Git remote and tries to git clone it at the specified rev. If
grammars/tree-sitter-cirru/ is not itself a Git repo (e.g. after a fresh clone of the
parent project), Zed will fail with a checkout error.
Fix: initialise it as a Git repo and create a commit:
cd grammars/tree-sitter-cirru
git init && git add -A && git commit -m "tree-sitter grammar for cirru"Then update the rev in extension.toml to the new commit hash:
git rev-parse HEAD # copy this hash into extension.tomlThe repository field under [grammars.cirru] contains an absolute local path
(e.g. file:///Users/<username>/repo/cirru/zed-cirru/grammars/tree-sitter-cirru).
Make sure this matches the actual path on your machine.
Zed expects to clone the grammar into grammars/cirru/ itself. If that directory
already exists (even if empty), Zed will refuse to proceed with:
grammar directory '…/grammars/cirru' already exists, but is not a git clone of '…'
Fix: remove the directory and let Zed recreate it:
rm -rf grammars/cirruThe top-level .gitignore excludes many generated files under
grammars/tree-sitter-cirru/ (bindings, Cargo.toml, node_modules, etc.).
These are not needed for Zed to compile the grammar — Zed only requires
src/parser.c and the header files in src/tree_sitter/. As long as those exist
(they are tracked in Git), the extension will build correctly.