Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Missing highlight on some keywords #3

Closed
hlbstd opened this issue Apr 1, 2019 · 5 comments
Closed

Missing highlight on some keywords #3

hlbstd opened this issue Apr 1, 2019 · 5 comments

Comments

@hlbstd
Copy link

hlbstd commented Apr 1, 2019

When writing the following example, the only recognized token is the class name test, which gets properly highlighted as a type:
template<typename T> class test {};
The template, typename and class keywords are not recognized. This is true whether the class is templated or not. This is true for most c++ keywords/qualifiers such as struct, const, etc.
LspCxxHlCursorSym command yields no results for these keywords, and the LspCxxHlIgnoredSyms returns an empty list.

I am unsure whether this is an issue with LspCxxHl or the intended design for the plugin to rely for some part on the default c.vim highlight groups, in which case I assume I should modify some highlight bindings (which ones?) to better differentiate between types and keywords as it is visible in your example image.

I have some more examples of seemingly silently ignored symbols (the template parameter in my previous example is one), tell me if you want a different issue for these. I can provide my log if you're interested.

@jackguo380
Copy link
Owner

Unfortunately this isn't a bug in vim-lsp-cxx-highlight. ccls/cquery do not send keywords in the semantic highlighting information. I believe this is correct behavior since these keywords can be statically highlighted by regexes, sending them over LSP would introduce unnecessary overhead.

The issue you are running into is that Vim's own C++ syntax highlighting isn't very good. Notably many C++ keywords like virtual and others are missing or incorrectly categorized. For my personal setup I use vim-cpp-modern to fix these highlighting errors. I don't plan on integrating these into vim-lsp-cxx-highlight since it would just be reinventing the wheel.

@hlbstd
Copy link
Author

hlbstd commented Apr 1, 2019

Thank you for your answer. Using vim-cpp-modern in conjunction with your plugin seems to give pretty good results, it might be worth it to specify that not all symbols are treated by lsp-cxx-highlight by design in the wiki/readme/doc. If it's there and I've missed it, my bad.

As I said I still have some symbols other than keywords that are not highlighted properly, albeit with similar symptoms. Do you want another issue on the matter ?

@jackguo380
Copy link
Owner

jackguo380 commented Apr 1, 2019

Ah sorry I missed that part about templates. I have seen that as well and suspect it's due to ccls missing some template parameters in its index since I don't see the same issue using cquery.

I was planning on filing a issue myself as well, but it would be great if you could dig more into this. No need to make a new issue, using this one is okay.

Edit:
No I didn't mention it in any wiki/doc, that's a good idea, I'll update the README.md to include these.

@jackguo380
Copy link
Owner

Looks like template parameters will be highlighted if you build with LLVM 9 (currently in development), see this issue I posted: MaskRay/ccls#364.
ccls has a guide on building LLVM from trunk here: https://github.com/MaskRay/ccls/wiki/Build.

@FelipeLema
Copy link

for whoever arrives here looking for semantic tokens support from ccls: I'm working on a PR for Semantic Tokens here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants