Rainbow delimiters for Neovim
Warning
This plugin is deprecated! Please use rainbow-delimiters.nvim instead (GitHub mirror). This plugin is implemented as a module for nvim-treesitter, but nvim-treesitter has deprecated the module feature. Hence why I have created a new standalone plugin which does not depend on nvim-treesitter.
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.
Installation and setup
Installation
The plugin depends on nvim-treesitter. Other than that it is installed like any other Neovim plugin.
Setup
Since this is a module for nvim-treesitter you need to setup everything in its configuration. Here is an example:
require('nvim-treesitter.configs').setup {
rainbow = {
enable = true,
-- list of languages you want to disable the plugin for
disable = { 'jsx', 'cpp' },
-- Which query to use for finding delimiters
query = 'rainbow-parens',
-- Highlight the entire buffer all at once
strategy = require('ts-rainbow').strategy.global,
}
}
Please refer to the manual for more details.
Help wanted
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.
Status of the plugin
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.
Warning
There is currently a shortcoming in Neovim's Tree-sitter API which makes it so that only the first node of a capture group can be highlighted. Please see neovim/neovim#17099 for details. Affected queries:
- HTML
rainbow-parens
- JSX (Javascript + React.js)
rainbow-parens-react
(affects React tags only) - Python (
rainbow-parens
) (affects only thefor ... in
inside comprehensions) - TSX (Typescript + React.js)
rainbow-parens-react
(affects React tags only) - Vue.js
rainbow-parens
Most of these are related to HTML-like tags, so you can use an alternative
query instead. See the manual (:h ts-rainbow-query
) for a list of extra
queries.
Screenshots
Bash
C
Common Lisp
Java
LaTeX
Using the blocks
query to highlight the entire \begin
and \end
instructions.
License
Licensed under the Apache-2.0 license. Please see the LICENSE file for details.
Attribution
This is a fork of a previous Neovim plugin, the original repository is available under https://sr.ht/~p00f/nvim-ts-rainbow/.
Attributions from the original author
Huge thanks to @vigoux, @theHamsta, @sogaiu, @bfredl and @sunjon and @steelsojka for all their help