This Neovim plugin provides alternating syntax highlighting (“rainbow parentheses”) for Neovim, powered by Tree-sitter. The goal is to have a hackable plugin which allows for different configuration of queries and strategies, both globally and per file type. Users can override and extend the built-in defaults through their own configuration.
This is a fork of nvim-ts-rainbow2, which was implemented as a module for nvim-treessiter. However, since nvim-treesitter has deprecated the module system I had to create this standalone plugin.
Install it like any other Neovim plugin; you do not need the Git submodules of this repository. They are just used for development and won't cause any harm, they will just bloat your setup.
You will need a Tree-sitter parser for each language you want to use rainbow delimiters with.
No configuration is needed to get started, this plugin has reasonable defaults
which you can override. Configuration is done by setting entries in the Vim
script dictionary g:rainbow_delimiters
. Here is an example configuration:
let g:rainbow_delimiters = {
\ 'strategy': {
\ '': 'rainbow-delimiters.strategy.global',
\ 'vim': 'rainbow-delimiters.strategy.local'
\ },
\ 'query': {
\ '': 'rainbow-delimiters',
\ 'lua': 'rainbow-blocks',
\ },
\ 'priority': {
\ '': 110,
\ 'lua': 210,
\ },
\ 'highlight': [
\ 'RainbowDelimiterRed',
\ 'RainbowDelimiterYellow',
\ 'RainbowDelimiterBlue',
\ 'RainbowDelimiterOrange',
\ 'RainbowDelimiterGreen',
\ 'RainbowDelimiterViolet',
\ 'RainbowDelimiterCyan',
\ ],
\ }
The equivalent code in Lua:
---@type rainbow_delimiters.config
vim.g.rainbow_delimiters = {
strategy = {
[''] = 'rainbow-delimiters.strategy.global',
vim = 'rainbow-delimiters.strategy.local',
},
query = {
[''] = 'rainbow-delimiters',
lua = 'rainbow-blocks',
},
priority = {
[''] = 110,
lua = 210,
},
highlight = {
'RainbowDelimiterRed',
'RainbowDelimiterYellow',
'RainbowDelimiterBlue',
'RainbowDelimiterOrange',
'RainbowDelimiterGreen',
'RainbowDelimiterViolet',
'RainbowDelimiterCyan',
},
}
Please refer to the manual for more details. For those who prefer a setup
function there is the module rainbow-delimiters.setup
that accepts all the
same parameters as g:rainbow-delimiters
.
require('rainbow-delimiters.setup').setup {
strategy = {
-- ...
},
query = {
-- ...
},
highlight = {
-- ...
},
}
There are only so many languages which I understand to the point that I can write queries for them. If you want support for a new language please consider contributing code. See the CONTRIBUTING for details.
TL;DR: Run these steps first if you want to run tests:
ln -s .submodules .gitmodules
git submodule init
git submodule updated --checkout
To provide some context, there are dependencies needed to run tests. These are included as Git submodules. The problem is that a number of package managers will download submodules by default, which means that users will end up with a bunch of stuff installed that they don't want. There is no way to tell Git to use a different file, so we have to create a symbolic link instead if we actually do want to download these submodules.
Tree-sitter support in Neovim is still experimental. This plugin and its API should be considered stable insofar as breaking changes will only happen if changes to Neovim necessitates them.
Licensed under the Apache-2.0 license. Please see the LICENSE file for details.
Rainbow-Delimiters uses different settings than nvim-ts-rainbow2, but converting the configuration is straight-forward. The biggest change is where the settings are stored.
- Settings are stored in the global variable
g:rainbow-delimiters
, which has the same keys as the old settings - The default strategy and query have index
''
(empty string) instead of1
- Default highlight groups have the prefix
RainbowDelimiter
instead ofTSRainbow
, e.g.RainbowDelimiterRed
instead ofTSRainbowRed
- The default query is now called
rainbow-delimiters
instead ofrainbow-parens
- The public Lua module is called
rainbow-delimiters
instead ofts-rainbow
The name of the default query is now rainbow-delimiters
because for some
languages like HTML the notion of "parentheses" does not make any sense. In
HTML the only meaningful delimiter is the tag. Hence the generic notion of a
"delimiter".
This is a fork of a previous Neovim plugin, the original repository is available under https://sr.ht/~p00f/nvim-ts-rainbow/.
Huge thanks to @vigoux, @theHamsta, @sogaiu, @bfredl and @sunjon and @steelsojka for all their help





Using the rainbow-blocks
query to highlight the entire \begin
and \end
instructions.

Using the rainbow-blocks
query to highlight the entire keywords like
function
, if
, else
and end
.
