Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tree-sitter/tree-sitter/llms.txt
Use this file to discover all available pages before exploring further.
Code of Conduct
Contributors to Tree-sitter should abide by the Contributor Covenant.Developing Tree-sitter
Prerequisites
To make changes to Tree-sitter, you should have:- A C compiler, for compiling the core library and the generated parsers.
- A Rust toolchain, for compiling the Rust bindings, the highlighting library, and the CLI.
- Node.js and NPM, for generating parsers from
grammar.jsfiles. - Either Emscripten, Docker, or podman for compiling the library to Wasm.
Building
Clone the repository:tree-sitter playground command will require an internet connection. If you have Emscripten installed, this will use your emcc compiler. Otherwise, it will use Docker or Podman:
tree-sitter CLI executable in the target/release folder.
If you want to automatically install the tree-sitter CLI in your system, you can run:
release-dev profile:
Testing
Before you can run the tests, you need to fetch some upstream grammars that are used for testing:Wasm Stdlib
The tree-sitter Wasm stdlib can be built via xtask:TREE_SITTER_WASI_SDK_PATH environment variable. You can download it from the releases page.
Similarly, this command also looks for the wasm-opt tool from binaryen indicated by the TREE_SITTER_BINARYEN_PATH environment variable. You can download it from the releases page.
Any changes to
crates/language/wasm/** requires rebuilding the tree-sitter Wasm stdlib via cargo xtask build-wasm-stdlib.Debugging
The test script has a number of useful flags. You can list them all by runningcargo xtask test -h.
If you want to run a specific unit test, pass its name (or part of its name) as an argument:
lldb or gdb) using the -g flag:
-l flag. Additionally, if you want to run a particular example from the corpus, you can pass the -e flag:
lldb to debug the C library, tree-sitter provides custom pretty printers for several of its types. You can enable these helpers by importing them:
Published Packages
The maintree-sitter/tree-sitter repository contains the source code for several packages that are published to package registries:
Rust Crates on crates.io
tree-sitter
A Rust binding to the core library
tree-sitter-config
User configuration of the command-line tool
tree-sitter-cli
The command-line tool
tree-sitter-generate
The parser-generation library
tree-sitter-highlight
The syntax-highlighting library
tree-sitter-language
Language type for grammars
tree-sitter-loader
Parser building and loading library
tree-sitter-tags
The syntax-tagging library
JavaScript Modules on npmjs.com
web-tree-sitter
A Wasm-based JavaScript binding to the core library
tree-sitter-cli
The command-line tool
Other Language Bindings
There are also several other dependent repositories that contain published packages:node-tree-sitter
Node.js bindings published as
tree-sitter on npmjs.compy-tree-sitter
Python bindings published as
tree-sitter on PyPI.orggo-tree-sitter
Go bindings published as
tree_sitter on pkg.go.devRelease Workflow
Tree-sitter follows semver (pre-1.0.0) with a dual development strategy:- All development happens on the
masterbranch. Any new PR (bugfix or feature) must targetmaster. - Applicable bugfixes and minor improvements are backported to the latest
release-0.xbranch.
tree-sitter-language, which is versioned independently and only bumped when necessary.
Minor Releases
Minor releases (0.x.0) are made from the master branch:
- Create a “release
v0.x.0” PR onmasterand apply theci:check releaselabel - If indicated, bump the patch version of the language crate
- Once the PR is merged, tag the commit and push via
git push --tags - Edit the GitHub release to include release notes
- Create a new
release-0.xbranch and push to GitHub - Bump all version numbers (except language crate) to
0.{x+1}.0
Patch Releases
Patch releases (0.x.y) are made from the release-0.x branch:
- Bump all version numbers (except language crate) to
0.x.y - Create a “release
v0.x.y” PR onrelease-0.xand apply theci:check releaselabel - If indicated, bump the patch version of the language crate
- Once the PR is merged, tag the commit and push via
git push --tags - Edit the GitHub release to include release notes
Developing Documentation
The documentation is built usingmdBook. Most of the documentation is written in Markdown, and you can find these files at docs/src.