Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork59
Rainbow delimiters for Neovim with Tree-sitter
License
HiPhish/rainbow-delimiters.nvim
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This Neovim plugin provides alternating syntax highlighting (“rainbowparentheses”) for Neovim, powered byTree-sitter. The goal is to have ahackable plugin which allows for different configuration of queries andstrategies, both globally and per file type. Users can override and extend thebuilt-in defaults through their own configuration.
This is a fork ofnvim-ts-rainbow2, which was implemented as a module fornvim-treessiter. However, since nvim-treesitter has deprecated the modulesystem I had to create this standalone plugin.
Install it like any other Neovim plugin; you do not need the Git submodules ofthis 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 rainbowdelimiters with.
No configuration is needed to get started, this plugin has reasonable defaultswhich you can override. Configuration is done by setting entries in the Vimscript dictionaryg:rainbow_delimiters. Here is an example configuration:
letg: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:
---@typerainbow_delimiters.configvim.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 themanual for more details. For those who prefer asetupfunction there is the modulerainbow-delimiters.setup that accepts all thesame parameters asg:rainbow-delimiters.
require('rainbow-delimiters.setup').setup {strategy= {-- ... },query= {-- ... },highlight= {-- ... },}
There are only so many languages which I understand to the point that I canwrite queries for them. If you want support for a new language please considercontributing code. See theCONTRIBUTING for details.
TL;DR: Run these steps first if you want to run tests:
ln -s .submodules .gitmodulesgit submodule initgit submodule updated --checkout
To provide some context, there are dependencies needed to run tests. These areincluded as Git submodules. The problem is that a number of package managerswill download submodules by default, which means that users will end up with abunch of stuff installed that they don't want. There is no way to tell Git touse a different file, so we have to create a symbolic link instead if weactually do want to download these submodules.
Tree-sitter support in Neovim is still experimental. This plugin and its APIshould be considered stable insofar as breaking changes will only happen ifchanges to Neovim necessitates them.
Licensed under the Apache-2.0 license. Please see theLICENSE file fordetails.
Rainbow-Delimiters uses different settings than nvim-ts-rainbow2, butconverting the configuration is straight-forward. The biggest change is wherethe settings are stored.
- Settings are stored in the global variable
g:rainbow-delimiters, which hasthe same keys as the old settings - The default strategy and query have index
''(empty string) instead of1 - Default highlight groups have the prefix
RainbowDelimiterinstead ofTSRainbow, e.g.RainbowDelimiterRedinstead ofTSRainbowRed - The default query is now called
rainbow-delimitersinstead ofrainbow-parens - The public Lua module is called
rainbow-delimitersinstead ofts-rainbow
The name of the default query is nowrainbow-delimiters because for somelanguages like HTML the notion of "parentheses" does not make any sense. InHTML 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 isavailable underhttps://sr.ht/~p00f/nvim-ts-rainbow/.
Huge thanks to @vigoux, @theHamsta, @sogaiu, @bfredl and @sunjon and@steelsojka for all their help





Using therainbow-blocks query to highlight the entire\begin and\endinstructions.

Using therainbow-blocks query to highlight the entire keywords likefunction,if,else andend.

About
Rainbow delimiters for Neovim with Tree-sitter
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.