// the find
jlcrochet/tree-sitter-razor
Razor grammar for Tree-sitter
A Tree-sitter grammar for Razor/Blazor syntax, enabling syntax highlighting and parsing in editors that use Tree-sitter (Neovim, Zed, etc.). Fills a real gap — Razor is notoriously hard to parse correctly because it mixes C#, HTML, and its own directive syntax. Zero stars suggests it's early or undiscovered, not that it's bad.
Full binding matrix out of the box (C, Go, Node, Python, Rust, Swift) — follows the standard tree-sitter-language scaffold properly. The external scanner (scanner.c) is the right approach for Razor's context-sensitive lexing, which can't be expressed in pure grammar rules. Test corpus is split by feature (control flow, directives, expressions, Blazor) rather than dumped in one file, which makes regressions easy to locate. The C# subgrammar is a git submodule rather than hand-rolled, so it tracks upstream correctness.
Zero stars and no releases means no community validation — you don't know yet which real-world Razor files it chokes on, and Razor syntax has enough edge cases (nested code blocks, generic type parameters in directives, @functions vs @code, component attributes with C# expressions) to break naive grammars badly. No queries beyond injections.scm — missing highlights.scm means editors won't get syntax highlighting without you writing it yourself. The generated parser.c is committed to the repo (70k+ lines typically), which is standard practice but means the diff story for grammar changes is ugly and git history is polluted. Last push February 2026 with no issues or PRs open — unclear if active or abandoned.