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] Arithmetic operation using `(( xxx ))` is rendered wrongly in bash/zsh #174

Open CoelacanthusHex opened 3 years ago

CoelacanthusHex commented 3 years ago

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

91khr commented 3 years ago

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