jackguo380 / vim-lsp-cxx-highlight

Vim plugin for C/C++/ObjC semantic highlighting using cquery, ccls, or clangd
MIT License
337 stars 26 forks source link

Feature request: annotations #57

Closed Falkgaard closed 3 years ago

Falkgaard commented 3 years ago

Hi, I use a lot of annotations such as [[nodiscard]], [[maybe_unused]], [[likely]], [[fallthrough]], etc. However, this plugin doesn't appear to provide any highlighting for these. Would it be possible to have that implemented as feature..?

Other than that I love the plugin, great work!

Regards, -Falkgaard


EDIT:

I added syntax match Annotation /\[\[\w\+\]\]/ to ~/.config/nvim/after/syntax/cpp.vim and then a highlight rule for Annotation to get it highlighted on my end.

jackguo380 commented 3 years ago

Highlighting attributes is actually very easy to implement in vim's own syntax highlighting because they don't require any compiler analysis unlike disguishing a variable from a macro or function. Also, ccls does not actually send any data for attributes so I can't really implement it in vim-lsp-cxx-highlight.

I usually recommend people use a "c++ syntax extension pack" like bfrg/vim-cpp-modern in addition since vim's included c++ syntax file is constantly out of date/incomplete. That plugin will highlight attributes if you set g:cpp_attributes_highlight = 1.

Alternatively, if you don't want that full plugin you can copy-paste the lines for attributes. IMO the use of the Identifier highlight group for the brackets is kind of weird, but you can always remap it to something else.

Falkgaard commented 3 years ago

Alright, fair enough!

Cheers for the speedy and helpful resolution.