tree-sitter-vue-next

A tree-sitter grammar and Rust bindings for parsing Vue single-file components, built on top of tree-sitter-html.

Library
Cargo
v0.1.0
0stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
9/100Needs Attention
Development Activity4
Maintenance0
Community8
Maturity24
Momentum0

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
40/100Fair
Architecture60
Code Quality45
Innovation10
Learning Curve45

tree-sitter-vue-next packages a tree-sitter grammar for Vue single-file component (.vue) files as a Cargo crate. The grammar extends tree-sitter-html with Vue-specific rules for <template>, <script>, and <style> blocks plus mustache interpolations, producing a concrete syntax tree usable for editor tooling, syntax highlighting, and static analysis.

The grammar itself originates from the tree-sitter-grammars/tree-sitter-vue project (the README, package.json, and tree-sitter.json metadata still credit that upstream project and its author). This crate republishes the grammar’s generated Rust bindings under a separate crates.io package name, since the upstream project itself has not published Rust bindings there.

What You Get

  • A compiled tree-sitter parser (LANGUAGE constant) for .vue files, ready to load into any tree-sitter::Parser.
  • Grammar rules for <template>, <script>, and <style> blocks plus Vue mustache interpolations, built on top of tree-sitter-html.
  • Bundled node-types.json and syntax-highlighting/injection query files for editor and tooling integration.
  • Cross-language bindings (Rust, Python, Node.js, C) generated from the same underlying grammar definition.

Common Use Cases

  • Powering .vue syntax highlighting in editors and terminal tools that embed tree-sitter.
  • Building static analysis or linting tools that need an accurate parse tree for Vue single-file components.
  • Feeding Vue template/script/style boundaries into code-intelligence features like folding, outlining, or go-to-definition.
  • Embedding Vue parsing in Rust-based tooling (e.g. formatters, codemods) via the crate’s LANGUAGE constant.

Under The Hood

Architecture The grammar extends the tree-sitter-html grammar (imported via import HTML from 'tree-sitter-html/grammar.js' in grammar.js) and augments it with Vue-specific node types — template_element and interpolation — plus custom start/end-tag handling for <template>, <script>, and <style> blocks. Context-sensitive tokens (template start-tag names, text fragments, interpolation text) are resolved via externals backed by a hand-written C scanner (src/scanner.c); the compiled src/parser.c is the generated parse table from grammar.js via the tree-sitter CLI. Rust bindings (bindings/rust/lib.rs) expose a LANGUAGE constant wrapping the C tree_sitter_vue() FFI symbol and re-export node-types.json and query files as embedded string constants, with equivalent bindings for Node, Python, and C. There is no independent business logic beyond the standard tree-sitter grammar-binding pattern — it is a declarative extension of an existing grammar plus generated boilerplate.

Tech Stack The grammar is defined in JavaScript (grammar.js) using the tree-sitter grammar DSL, compiled via the tree-sitter CLI into a C parser (src/parser.c) plus the hand-written C external scanner. The crate is distributed with multiple language bindings: a Rust crate (tree-sitter-language 0.1, built via bindings/rust/build.rs invoking cc 1.x, tested against tree-sitter 0.26 as a dev-dependency), Node.js bindings (node-addon-api, node-gyp-build, nan), and Python bindings (setup.py plus pyproject.toml). Build tooling includes a Makefile and CMakeLists.txt for native builds, GitHub Actions workflows for CI, fuzzing, and release automation, and a dependency on tree-sitter-html 0.23.2 as the base grammar.

Code Quality test/corpus/spec.txt contains hand-written parser test cases in tree-sitter’s corpus format (input snippets plus expected S-expression parse trees), run via tree-sitter test; the Rust bindings include one doctest in lib.rs. There is no additional unit-test suite, and no linter/formatter config beyond .editorconfig. This repository is a near-verbatim fork of tree-sitter-grammars/tree-sitter-vue — the README, package.json, and tree-sitter.json still reference the upstream repository and credit its original author — republished to crates.io under a new package name by changing only Cargo.toml; no grammar or scanner changes were made in this fork.

API Design The public Rust API is a single LANGUAGE constant plus re-exported NODE_TYPES, HIGHLIGHTS_QUERY, and INJECTIONS_QUERY string constants, matching the conventional shape of other tree-sitter grammar crates — low boilerplate to integrate, but no documentation was added beyond what the fork inherited. The -next package name suggests a successor or improvement over the upstream grammar, but the code is otherwise unchanged from the original project, so there’s no new developer-experience contribution beyond making an unpublished grammar installable from crates.io.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search