Skip to main content
The languages that go through tree-sitter (Go, C, and PowerShell) are parsed via pinned tree-sitter-<lang> crates. Grammars change over time and need periodic updates — both for bug fixes and to keep up with new syntax.
Kotlin is not tree-sitter-backed — it uses an ANTLR grammar. To regenerate the Kotlin parser, see Add a new language → Adding an ANTLR-backed language and cargo xtask antlr generate kotlin, not the tree-sitter flow below.
Grammars can be updated on Linux and macOS natively, or on Windows using WSL.

Currently pinned tree-sitter grammars

Each grammar is inline-pinned in its owning crates/mehen-<lang>/Cargo.toml — the analyzer crate is the single source of truth. xtask never pins a grammar itself; the kind-enum generator reaches each grammar through the analyzer crate’s __grammar_language() accessor (a path dependency), so the codegen and the runtime parser always link the exact same revision. Bumping the pin in the analyzer’s Cargo.toml is therefore enough — there is no second [workspace.dependencies] line to keep in sync.
GrammarOwning crateGenerated grammar.rs?
tree-sitter-cmehen-cYes — codegen target c
tree-sitter-gomehen-goYes — codegen target go
tree-sitter-pwshmehen-powershellNo — matches string node-kinds directly
PowerShell is tree-sitter-backed but has no generated grammar.rs and is not an xtask codegen target. mehen-powershell matches node kinds by their string names against tree_sitter_pwsh::LANGUAGE at runtime, so bumping tree-sitter-pwsh needs no kind-enum regeneration — only C and Go do.
The Python, TypeScript / JavaScript / TSX / JSX, PHP, Ruby, Rust, Kotlin, Java, SQL, and Markdown analyzers do not use tree-sitter; they have no grammar.rs and need no kind-enum regeneration. (Kotlin and Java are ANTLR-backed — see the note above; SQL uses sqruff and Markdown uses pulldown-cmark.)

Update process

1

Bump the pin

Update the single inline pin in the owning crates/mehen-<lang>/Cargo.toml:
tree-sitter-c = "=x.xx.x"
xtask picks up the new revision automatically through the mehen-<lang> path dependency, so there is no separate xtask/Cargo.toml or [workspace.dependencies] line to bump.
2

Regenerate kind enums

cargo xtask tree-sitter generate --all
This rewrites every codegen-target crate’s grammar.rs (C and Go) from the pinned grammar’s node-kind table. CI runs cargo xtask tree-sitter check-generated to ensure pinned-grammar bumps without a regenerate are caught at PR time. (PowerShell has no grammar.rs, so bumping tree-sitter-pwsh skips this step.)
3

Fix breakage

New node kinds may appear (and need handling), and existing node kinds may be renamed or restructured. Update analyzer code accordingly.
4

Run validation

cargo nextest run --all-features
cargo insta test --workspace --all-features --check --unreferenced reject \
    --test-runner nextest --no-test-runner-fallback --disable-nextest-doctest
cargo clippy --all-targets --all-features --locked
5

Open a PR

Commit the updated Cargo.toml, Cargo.lock, and any regenerated grammar.rs files.

Automation

Dependabot raises grammar bump PRs automatically. The regenerate-grammars workflow detects those PRs (branch name contains tree-sitter) and runs cargo xtask tree-sitter generate --all plus the test suite, then commits the regenerated files back to the PR branch. Reviewers should still verify analyzer code still handles any renamed kinds.

See also