HiPhish / rainbow-delimiters.nvim

Rainbow delimiters for Neovim with Tree-sitter
https://gitlab.com/HiPhish/rainbow-delimiters.nvim
Apache License 2.0
490 stars 37 forks source link

[Bug]: Possible regression, can't implement whitelist only rainbow delimiters #8

Closed davidsierradz closed 1 year ago

davidsierradz commented 1 year ago

Neovim version

nightly

Language affected

No response

Query

No response

Strategy

No response

Description

Hi, before commit bc1e12be89d46190f4ca798e10a9203d90248b22, I could implement a whitelist only setup enabled with a defined set of languages:

local rainbow_delimiters = require('rainbow-delimiters')

vim.g.rainbow_delimiters = {
  strategy = {
    [''] = rainbow_delimiters.strategy['noop'],
    clojure = rainbow_delimiters.strategy['global'],
    fennel = rainbow_delimiters.strategy['global'],
    commonlisp = rainbow_delimiters.strategy['global'],
    query = rainbow_delimiters.strategy['global'],
    janet = rainbow_delimiters.strategy['global'],
    racket = rainbow_delimiters.strategy['global'],
    scheme = rainbow_delimiters.strategy['global'],
  },
  highlight = {
    '@rainbow.1',
    '@rainbow.2',
    '@rainbow.3',
    '@rainbow.4',
    '@rainbow.5',
    '@rainbow.6',
  },
}

Basically, I want to enable rainbow delimiters only on lisp-like languages, is this use-case valid?

Thanks

HiPhish commented 1 year ago

Does setting the strategy to noop not work?

Basically, I want to enable rainbow delimiters only on lisp-like languages, is this use-case valid?

That does sound like a reasonable thing to want to do. I think having an explicit whitelist and blacklist in the settings would be better, otherwise I have to run a bunch of logic and waste resources just to set up a bunch of machinery that does nothing.

davidsierradz commented 1 year ago

Does setting the strategy to noop not work?

Yeah, after commit bc1e12be89d46190f4ca798e10a9203d90248b22:

image

Before (5a074244a40f9e2e0ba219268c69cb256ce16696):

image

Same config:

local rainbow_delimiters = require('rainbow-delimiters')

vim.g.rainbow_delimiters = {                            
  strategy = {                                          
    [''] = rainbow_delimiters.strategy['noop'],         
    clojure = rainbow_delimiters.strategy['global'],    
    fennel = rainbow_delimiters.strategy['global'],     
    commonlisp = rainbow_delimiters.strategy['global'], 
    query = rainbow_delimiters.strategy['global'],      
    janet = rainbow_delimiters.strategy['global'],      
    racket = rainbow_delimiters.strategy['global'],     
    scheme = rainbow_delimiters.strategy['global'],     
  },                                                    
  highlight = {                                         
    '@rainbow.1',                                       
    '@rainbow.2',                                       
    '@rainbow.3',                                       
    '@rainbow.4',                                       
    '@rainbow.5',                                       
    '@rainbow.6',                                       
  },                                                    
}                                                       
HiPhish commented 1 year ago

The fallback setting should work now again. Please try out the latest master. I still want to implement white- and blacklist eventually, but this should work in the meantime.

davidsierradz commented 1 year ago

Thanks! Confirming that it works again!

HiPhish commented 1 year ago

FYI, white- and blacklisting is implemented now. You can add an explicit list of languages for which you want rainbow delimiters enabled:

vim.g.rainbow_delimiters = {
    -- ... your configuration
    whitelist = {'commonlisp', 'clojure', 'scheme', 'fennel', 'janet', 'racket'}
}

This will abort the machinery much earlier than if you set noop as your strategy.