tree-sitter-astro-next
An Astro grammar for tree-sitter, compatible with tree-sitter 0.25+
Repository Health
Technical Analysis
tree-sitter-astro-next is a tree-sitter grammar for the Astro web framework’s file format, compatible with tree-sitter 0.25 and later. It parses Astro components into a concrete syntax tree that updates incrementally as code changes, enabling syntax highlighting, code navigation, and other editor features for Astro files.
The grammar handles Astro’s distinctive structure, including the frontmatter fence, HTML-like template markup, and embedded expressions, and ships as a Rust crate for use in tree-sitter-based editors and tooling.
What You Get
- A tree-sitter grammar for Astro files with a generated C parser
- Compatibility with tree-sitter 0.25 and later versions
- Support for Astro frontmatter blocks, template markup, and embedded expressions
- A Rust crate for integrating Astro parsing into editors and tools
Common Use Cases
- Syntax highlighting for Astro files in tree-sitter-based editors
- Code navigation and structural editing of Astro components
- Editor and language-tooling support for the Astro framework
- Static analysis of Astro frontmatter and template markup
Under The Hood
Architecture - The grammar is defined in grammar.js using tree-sitter’s DSL and compiled to a C parser with an external scanner that separates Astro’s frontmatter fence from its HTML-like template body and embedded expressions. The binding exposes a language() entry point for a tree-sitter runtime.
Tech Stack - The generated parser is C (the repo’s primary language); the grammar definition is JavaScript. The package is published as a Rust crate targeting tree-sitter 0.25+, built with the standard tree-sitter binding toolchain.
Code Quality - A newer, single-maintainer grammar focused on tree-sitter 0.25 compatibility. It is early-stage (v0.1.x) with modest adoption, but explicitly documents its Astro-specific syntax handling in the README.
API Design - Usage is a single call: import the binding and pass its language object to a tree-sitter parser. The -next naming signals it as an updated grammar aligned with recent tree-sitter releases.