rainbow icon indicating copy to clipboard operation
rainbow copied to clipboard

[Bug] Arithmetic operation using `(( xxx ))` is rendered wrongly in bash/zsh

Open CoelacanthusHex opened this issue 4 years ago • 1 comments

Describe the bug

Arithmetic operation using (( xxx )) is rendered wrongly, it has two color, but it should have only one color in syntax.

To Reproduce

Steps to reproduce the behavior, Please provide a minimal piece of code to produce this issue, along with it's filename and it's filetype detected by vim (via :set ft?), a piece of text is better than a picture here. For example:

File: bug.zsh, filetype=zsh

(( 12344 == 16777216 ))

Steps:

  1. Open file via vim bug.zsh
  2. See the color of (( and ))

Expected behavior

two brackets is rendered as same color as syntax

Screenshots

图片

Additional context

If the technology does not work, please turn off this plugin for bash and zsh like sh. As here: https://github.com/luochen1990/rainbow/commit/108eb2b93f5b280806552f5100b67286454ea4a3#diff-3ec0c4a499b949d280a477e6ea520fc842dc3db99a83c9281573ed59af0d4ff5R43

CoelacanthusHex avatar Nov 29 '21 09:11 CoelacanthusHex

Following config fixes this, and similar issue on other shells can be fixed similarly:

let g:rainbow_conf = #{
            \     separately: #{
            \         zsh: #{
            \             parentheses: ['start=/((/ end=/))/', 'start=/\v\(\ze($|[^(])/ end=/)/',
            \                 'start=/(/ end=/)/ contained containedin=zshMathSubst',
            \                 'start=/\V[[/ end=/]]/', 'start=/\v\[\ze($|[^[])/ end=/]/',
            \                 'start=/{/ end=/}/'],
            \         },
            \     },
            \ }

There is some work on adding a 'cluster' mechanic like vim's to add more flexibility for more complex occasions... But is it worth the cost... ? > < (A draft with feature added but without document updated is at https://github.com/91khr/rainbow

91khr avatar Dec 04 '21 13:12 91khr