rainbow icon indicating copy to clipboard operation
rainbow copied to clipboard

[Bug] Some lisp parentheses not highlighted properly

Open narimiran opened this issue 6 years ago • 5 comments

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.

narimiran avatar Dec 18 '19 10:12 narimiran

@narimiran can you show me your configuration?

luochen1990 avatar Dec 19 '19 02:12 luochen1990

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 avatar Dec 19 '19 05:12 narimiran

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

@luochen1990 any chance that this might get fixed?

narimiran avatar Apr 23 '20 18:04 narimiran

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?

narimiran avatar Apr 24 '20 20:04 narimiran

@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.

luochen1990 avatar May 12 '20 07:05 luochen1990