octol / vim-cpp-enhanced-highlight

Additional Vim syntax highlighting for C++ (including C++11/14/17)
MIT License
1.07k stars 150 forks source link

Add option to not highlight std:: namespace functions (i.e., cppSTLfunction) unless prefixed with std:: #36

Open anntzer opened 8 years ago

anntzer commented 8 years ago

There's a lot of names defined in the cppSTLfunction syntax group. In practice this easily leads to spurious highlighting, especially in a programming style where these functions would always be called with the std:: namespace explicitly.

Bonus points if you can auto-detect whether there's a using namespace std; in the current scope, but I think this may be a bit too difficult to be worth it?

octol commented 7 years ago

Sounds like something that could be useful to look into in the future. Thanks for the suggestion.

anntzer commented 7 years ago

Something like

syntax region cppSTLscoped start='\(std\)\@3<=::\<' end='\>' contains=cppSTLtype

syntax keyword cppSTLtype allocator contained
syntax keyword cppSTLtype auto_ptr contained
syntax keyword cppSTLtype basic_filebuf contained
...

(with separate groups for each namespace if we want to actually check the namespace, or with a single container group just checking for a preceding ::) works.