I'm using vim 8 to code C++11.

I've installed the vim plugins: YCM, ALE, vim-code-dark and vim-cpp-enhanced-highlight, however, it seems that there is some error on syntax highlighting.

enter image description here

As you see, scene and arg are highlighted with yellow, but they are variables, which shouldn't be highlighted, just like isColor, it seems that both of them are regarded as functions, I think the reason is the way of initialization: string arg("XXX");. It seems that this kind of initialization is regarded as a declaration of function, instead of a variable.

I don't know who is controlling this mechanism. Is it vim 8? or the vim plugins, such as YCM, ALE?

Is there some way to fix this error?

  • You’ll probably need to talk to the relevant plugin author. We have a handy question about debugging to find out where it’s coming from. The general idea is to start clean and try plugins one at a time until you find a combo that triggers it. I would bet it’s either enhanced highlight or vim defaults though. vi.stackexchange.com/q/2003/10604 – D. Ben Knoble Mar 28 at 3:04
  • @D.BenKnoble Thanks. Well, I just removed vim-code-dark and vim-cpp-enhanced-highlight, all becomes white except the C++ keywords. Then I added vim-code-dark back, it only changed the colors of the C++ keywords. So I think this issue comes from vim-cpp-enhanced-highlight. – Yves Mar 28 at 3:16
  • @D.BenKnoble But , in vim 7, vim-cpp-enhanced-highlight can not highlight the custom class name (SysTool in this example), so I think vim 8 do something too. So you are right about "either enhanced highlight or vim 8"... – Yves Mar 28 at 3:19
  • @D.BenKnoble Well, it seems that this issue is not a piece of cake... :D – Yves Mar 28 at 3:20
  • Try let g:cpp_no_function_highlight = 1 ? That will disable highlighting of user defined functions... Yes it will disable more than these two cases, but maybe that's acceptable to you? – filbranden Mar 28 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.