luochen1990 / rainbow

Rainbow Parentheses Improved, shorter code, no level limit, smooth and fast, powerful configuration.
Apache License 2.0
1.79k stars 97 forks source link

[Bug] Some lisp parentheses not highlighted properly #136

Open narimiran opened 4 years ago

narimiran commented 4 years ago

Describe the bug

Some lisp parentheses — those that have ' or ` before the opening parenthesis — are not highlighted properly.

To Reproduce

In the following example, notice #'(lambda ... part. Everything following it won't be highlighted.

(defun where (&key title artist rating)
  #'(lambda (cd)
       (and
         (if title  (equal (getf cd :tit) title) t)
         (if artist (equal (getf cd :art) artist) t)
         (if rating (equal (getf cd :rat) rating) t))))

If you introduce a whitespace between #' and (lambda then it is highlighted normally. (See screenshot below)

Screenshots

screenshot1

screenshot2

Additional context

I've tried to manually fix it by changing the rule for parentheses to allow optional characters before (, but I was not able to make it work.

luochen1990 commented 4 years ago

@narimiran can you show me your configuration?

narimiran commented 4 years ago
let g:rainbow_conf = {
\  'guifgs': ['lightblue', 'darkorange3', 'seagreen3', 'firebrick'],
\  'ctermfgs': ['green', 'yellow', 'darkblue', 'magenta'],
\  'separately': {
\    'pascal': {
\      'parentheses': ['start=/(\ze[^*]/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\[|/ end=/|\]/ fold', 'start=/{/ end=/}/ fold']
\  }}
\}
let g:rainbow_active = 1
nmap <leader>hh :RainbowToggle<CR>

And I use https://github.com/kovisoft/slimv for Lisp.

narimiran commented 4 years ago

Some lisp parentheses — those that have ' or ` before the opening parenthesis — are not highlighted properly.

@luochen1990 any chance that this might get fixed?

narimiran commented 4 years ago

Update:

I've managed to fix this by adding the following rule to my config for racket (the same should be for lisp too):

let g:rainbow_conf = {
\  'guifgs': ['lightblue', 'darkorange2', 'darkcyan',  'firebrick', 'seagreen2', 'magenta'],
\  'ctermfgs': ['green', 'yellow', 'darkblue', 'magenta'],
\  'separately': {
\    'pascal': {
\      'parentheses': ['start=/(\ze[^*]/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\[|/ end=/|\]/ fold', 'start=/{/ end=/}/ fold'],
\  },
\    'racket': {
\      'parentheses': ["start=/(/ end=/)/ fold", "start=/`(/ end=/)/ fold", "start=/'(/ end=/)/ fold", 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\} } }

Is there a better way than doing this one by one, and also duplicating what is in default rule for parentheses?

luochen1990 commented 4 years ago

@narimiran

Is there a better way than doing this one by one, and also duplicating what is in default rule for parentheses?

Actually, VimScript provided the map function, so you can use this to reduce the duplications, use :h map() for more details.