What is nvim-treesitter?
Thenvim-treesitter plugin provides three core capabilities for Neovim:
- Parser management: Functions for installing, updating, and removing Tree-sitter parsers for over 300 programming languages
- Query collections: Curated sets of queries that enable Tree-sitter features built into Neovim (highlighting, folding, indentation, injections)
- Experimental features: A staging ground for Tree-sitter-based functionality considered for upstreaming to Neovim core
This plugin focuses on parser and query management. The actual Tree-sitter features (like syntax highlighting) are built into Neovim itself.
Why use nvim-treesitter?
Tree-sitter provides several advantages over traditional regex-based syntax:- Accurate parsing: Tree-sitter builds a complete syntax tree, understanding your code’s structure
- Performance: Incremental parsing means only changed portions are re-parsed
- Consistency: The same parser powers highlighting, navigation, text objects, and more
- Language support: Over 300 languages with actively maintained parsers
Key capabilities
Syntax highlighting
Enable Tree-sitter-based syntax highlighting for rich, accurate code coloring
Code folding
Fold code blocks intelligently based on syntax structure
Indentation
Experimental Tree-sitter-based automatic indentation
Language injections
Support for multi-language documents like Markdown with code blocks
Quick example
Here’s how to install parsers and enable highlighting:Requirements
Before installing nvim-treesitter, ensure you have:- Neovim 0.11.0 or later (nightly builds are supported)
tarandcurlin your PATH for downloading parserstree-sitter-cliversion 0.26.1 or later- A C compiler for building parsers from source
Supported languages
The plugin supports parsers for over 300 languages, organized into tiers:- Stable: Follow semantic versioning for updates
- Unstable: Track the HEAD of the parser repository
- Unmaintained: No automatic updates available
- Unsupported: Known to be broken
- Highlights
- Folds
- Indents
- Injections (language injections)
- Locals (definitions and references)
What’s next?
Quickstart
Get up and running in under 5 minutes
Installation
Detailed installation instructions for all package managers
Configuration
Learn about setup options and customization
Commands
Reference for all available commands