jackguo380 / vim-lsp-cxx-highlight

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

Issues with `:set list` #9

Closed jbbudzon closed 5 years ago

jbbudzon commented 5 years ago

I recently got ccls and coc.nvim working for my c++ projects. I ❤️ this plugin! Makes syntax highlighting SOO much better!! One issue I have ran into though is with listchars and set list. The listchars are getting highlighted in a way that they shouldn't be.

I tried digging around in the code to see if I could come up with a fix but to no avail. I've never really done syntax highlighting in vim so I'm not the most familiar.

From what I've read though, NonText and SpecialText are what control highlighting of the variety of flags available in listchars.

Any idea how hard this would be to fix/implement??

jackguo380 commented 5 years ago

Hi jbbudzon, glad to hear this plugin is working well for you!

I tried :set list and changing listchars to different settings and didn't see any obviously broken behavior. Could you provide a screenshot of the problem?

jbbudzon commented 5 years ago

It may be that this is an LSP parsing issue and completely unrelated to your plugin. Screen Shot 2019-07-26 at 3 08 51 PM

If I run :highlight SpecialKey guifg=white guibg=black, then I get the following: Screen Shot 2019-07-26 at 3 09 37 PM

So you can see, it is not that SpecialKey isn't handled correctly but that somehow certain listchars aren't showing up as SpecialKey any longer. This leads me to believe the issue may not be related to your plugin.

Edit: And thank you very much for your help and for investigating the issue!!

jackguo380 commented 5 years ago

Ah okay, so you are saying that the tabs before the case should have a black background with white highlighting?

I tried it a random case statement in some code but am not seeing the issue: image

I don't think ccls sends keywords highlighting so case shouldn't be any different from what the vim syntax files define it as. Try putting your cursor over those tabs and running the command :LspCxxHlCursorSym.

I would expect the output to be the following (No symbol found):

Debug Find Cursor Symbol
Found:
End of Debug Find Cursor Symbol

If you are seeing a output like this then there potentially is a symbol at that location which may be a ccls bug or something:

Debug Find Cursor Symbol
Found:
Symbol: parentKind = Namespace, kind = EnumMember, storage = None, resolved hl group = LspCxxHlSymEnumMember
End of Debug Find Cursor Symbol
jbbudzon commented 5 years ago

I think you've hit the nail on the head. I ran those commands but wasn't sure how to parse the output. You've confirmed for me my suspicions.

When the cursor is on the tab before the case statement, I get

Debug Find Cursor Symbol
Found:
Symbol: parentKind = Unknown, kind = EnumMember, storage = None, resolved hl group = LspCxxHlSymEnumMember
End of Debug Find Cursor Symbol

Seems like a ccls bug to me 😉

jackguo380 commented 5 years ago

Are you using the sample configuration I provided/have the initialization option "highlight": { "lsRanges" : true }?

If not try enabling it in your coc-settings.json, I know that differing line endings can cause misalignment of highlight symbols.

jbbudzon commented 5 years ago

Feel like such an idiot! I misread your documentation and thought that was only required if byte_offset was missing. This totally fixed my issue. Thank you so very much!!