0

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?

Yves
  • 1,013
  • 1
  • 10
  • 25
  • 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. https://vi.stackexchange.com/q/2003/10604 – D. Ben Knoble Mar 28 '20 at 03: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 '20 at 03: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 '20 at 03:19
  • @D.BenKnoble Well, it seems that this issue is not a piece of cake... :D – Yves Mar 28 '20 at 03: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 '20 at 04:05
  • The match for custom function is way too simple, simply looks at a word followed by a ( and that's it: https://github.com/octol/vim-cpp-enhanced-highlight/blob/master/after/syntax/cpp.vim#L39 perhaps disabling it makes sense... – filbranden Mar 28 '20 at 04:11
  • OTOH, I believe in modern C++ you can use Scene scene{cols, lines}; and std::string arg{argv[1]};, right? – filbranden Mar 28 '20 at 04:12
  • Syntax is one of the most complicate stuff in vim, c++ is one of the most complicate programming language, two complicate stuff add together is too complicate. Let it go. I use vim-cpp-enchanced-highlight too, I see highlight mistake from time to time. Just let it go, it wont matter too much. – dedowsdi Mar 28 '20 at 05:51
  • @dedowsdi lol, I agree, let it go~ – Yves Mar 28 '20 at 06:50
  • @filbranden Good, let me disable it. – Yves Mar 28 '20 at 06:51

0 Answers0