What is a tree-sitter parser?
A tree-sitter parser is a language-specific library that analyzes source code and produces a concrete syntax tree (CST). Unlike traditional parsers, tree-sitter parsers are:- Incremental: They can reparse only the changed portions of a file
- Error-tolerant: They produce useful trees even for syntactically invalid code
- Fast: Parsing completes in milliseconds for most files
Each parser is a compiled C library specific to one programming language. nvim-treesitter manages installation and updates for over 300 languages.
Parser installation
nvim-treesitter provides multiple ways to install parsers:Using :TSInstall
The simplest method is the :TSInstall command:
Programmatic installation
You can also install parsers from Lua:This function runs asynchronously. For synchronous installation (e.g., in bootstrap scripts), use
:wait():Automatic updates
It’s recommended to automatically update parsers when upgrading nvim-treesitter. With lazy.nvim:Parser registry
All supported parsers are defined inlua/nvim-treesitter/parsers.lua. Each entry contains:
Parser tiers
nvim-treesitter uses a tiering system:- Tier 1 (Stable)
- Tier 2 (Unstable)
- Tier 3 (Unmaintained)
Preferred parsers that:
- Follow semantic versioning
- Provide WASM release artifacts
- Track versioned releases instead of HEAD
- Have active maintenance
python, inko, wit, zshParser requirements
Parser qualification criteria
For a parser to be included in nvim-treesitter, it must:- Correspond to a filetype detected by Neovim
- Be hosted or mirrored on GitHub
- Be covered by CI using upstream workflows
- Provide reference queries with validation
- Support the latest tree-sitter ABI
- Have external scanners written in C99 (if applicable)
Adding custom parsers
You can register parsers not included in nvim-treesitter:Using local parsers
Using local parsers
For local development, use a This will always use the directory as-is, ignoring
path instead of url:branch and revision fields.Registering filetypes
If the parser name differs from the Vim filetype:Parser compilation
When you install a parser, nvim-treesitter:- Downloads the source from the specified URL/revision
- Generates
src/parser.c(ifgenerate = trueor missing) - Compiles the parser and scanner into a shared library
- Installs the
.so/.dllfile to your configured directory
Parsers are installed to
{install_dir}/parser/{lang}.so where install_dir defaults to vim.fn.stdpath('data') .. '/site'.Working with parser source
Some parsers require special handling:Monorepo parsers
For parsers in subdirectories:Parsers requiring generation
If a repository doesn’t includesrc/parser.c:
External scanners
Parser dependencies
Some languages require other parsers:cpp, nvim-treesitter automatically installs the c parser first.
Checking parser health
Verify your parser installation:- Installed parsers and their versions
- Missing dependencies
- Compilation errors
- Query validation issues
Real-world examples
Here are some actual parser configurations from nvim-treesitter:Python (Tier 1)
Python (Tier 1)
Angular (with dependencies)
Angular (with dependencies)
CSV (monorepo)
CSV (monorepo)