Closed Curs3W4ll closed 2 years ago
Try to find out (you can use the tool in README.md) the syntax name of comment (when rainbow is disabled), and add something like following to your configuration ( replace xxxComment
to the real one ) :
let g:rainbow_conf = {
\ 'separately': {
\ 'cpp': {
\ 'parentheses_options': 'contains=@xxxComment',
\ }
\ }
\}
with :hi
, I found out that comments are identified with the syntax name Comment
So I updated my config to this:
let g:rainbow_conf = {
\ 'guifgs': ['magenta', 'coral2', 'gold', 'deepskyblue', 'slateblue'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,\|\.\|+\|-\|*\|\/\|%\|;\|=\|!\|<\|>_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'cpp': {
\ 'parentheses_options': 'contains=@Comment',
\ },
\ 'markdown': {
\ 'parentheses_options': 'containedin=markdownCode contained',
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'haskell': {
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'],
\ },
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody',
\ },
\ 'perl': {
\ 'syn_name_prefix': 'perlBlockFoldRainbow',
\ },
\ 'stylus': {
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'],
\ },
\ 'nerdtree': 0,
\ 'css': 0,
\ }
\}
But it has no effect
I cannot produce your issue, even without any extra rainbow configuration.
Have you enabled any 3rd-party syntax plugins for cpp?
I tried on a newly installed machine (with docker), using neovim v0.5.1, but the comment colorization keep being broke in .cpp files Only installed plugins are vimplug and the rainbow plugin.
The only configuration is the init.vim file containing the following:
call plug#begin()
Plug 'luochen1990/rainbow'
call plug#end()
hi Comment cterm=NONE ctermfg=red ctermbg=yellow
let g:rainbow_active = 1 " Load vim-rainbow for all the files
let g:rainbow_conf = {
\ 'guifgs': ['magenta', 'coral2', 'gold', 'deepskyblue', 'slateblue'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,\|\.\|+\|-\|*\|\/\|%\|;\|=\|!\|<\|>_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'cpp': {
\ 'parentheses_options': 'contains=@Comment',
\ },
\ 'markdown': {
\ 'parentheses_options': 'containedin=markdownCode contained',
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'haskell': {
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'],
\ },
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody',
\ },
\ 'perl': {
\ 'syn_name_prefix': 'perlBlockFoldRainbow',
\ },
\ 'stylus': {
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'],
\ },
\ 'nerdtree': 0,
\ 'css': 0,
\ }
\}
I changed comments highlight for better identification
Try to play a bit with the operators, I found out that the only operator causing problems is the /
one
If I switch my operators configuration to
\ 'operators': '_,\|\.\|+\|-\|*\|%\|;\|=\|!\|<\|>_',
Comments colorization is no more broken
Ok I don't know if this can help you, but I identify in which case the comment colorization get broke
An idea poped in my head when I found out that the problematic operator in cpp was /
, so I thought that this could be the 'comment identifier' (the character identifying a comment, //
in c/cpp, #
in bash/python, "
in vim....) that was causing problems when it was in the operators
So I tested it, I added the #
character in the operators list
And that's it !
Without the #
as an operator, python comment colorization is ok
But when I add the #
character as an operator in the rainbow config, it then broke the comment colorization
So the condition to broke comment colorization are
()
, []
, {}
)Have you any idea of how can I fix it ?
I suggest just remove /
from operators, the operators feature is not designed for mathmatic operators, but for seperators of items in parentheses, (maybe it should be called seperators
)
Alright thanks a lot !
Describe the bug
Removing comments grey colorizations when comments contain operators
To Reproduce
File:
bug.cpp
, filetype=cppSteps:
vim bug.js
Expected behavior
Comments should be grey as they are without the rainbow plugin
Screenshots
Expected![image](https://user-images.githubusercontent.com/72013831/169103961-47435f7e-0389-4c40-ab16-95c7e6f4d6ae.png)
With rainbow toggled OFF![image](https://user-images.githubusercontent.com/72013831/169104037-f6fae296-c783-4a4d-b77d-e4a9755b5133.png)
With rainbow toggled ON![image](https://user-images.githubusercontent.com/72013831/169104097-5797b08f-5272-4ab3-a499-e36211da637d.png)
Additional context
I use that config