LanguageClient-neovim icon indicating copy to clipboard operation
LanguageClient-neovim copied to clipboard

Preset LanguageClient_semanticHighlightMaps for known servers

Open YaLTeR opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe.

clangd and rust-analyzer (and maybe others) have semantic highlighting, would be nice if it worked out of the box.

Describe the solution you'd like

As far as I understand, vim has a number of preset highlight classes which are used by the built-in syntax highlighting. They very likely already look great on the user's theme. The default semanticHighlightMaps could map to these "built-in" highlight classes.

Describe alternatives you've considered

  1. Mapping to generic classes like LanguageClientType, LanguageClientMember, etc.

    This is less work for the user to set up as it's somewhat generic between different language servers, but it's still not out of the box.

Additional context

I'm not very familiar with vim syntax highlighting, maybe the built-in classes are not really sufficient?

YaLTeR avatar Feb 07 '21 07:02 YaLTeR

That is a great idea. We probably need to adjust the semantic highlighting implementation first though, as I believe that was a proposal in 3.16 when 3.15 was the current protocol version and it eventually got replaced/renamed by semantic tokens, which changes a few detail implementations. So probably a good place to start would be to add support for that again (possibly breaking the feature with servers that are stuck in the old, proposed implementation) and then adding our default mappings.

martskins avatar Feb 07 '21 19:02 martskins

@YaLTeR Just opened a draft #1194 to track progress on this. The implementation as it is now works (for the most part at least), but still needs mapping of lsp token types to vim highlight groups, I covered some of them but some others I didn't find a good option and left out. Also some of the highlight groups I chose are far less than ideal, so probably that is up for review as well.

To see it in action in that branch you have to manuall call :call LanguageClient#textDocument_semanticTokensFull(), as I still haven't decided on where the best place to call that one would be.

martskins avatar Feb 08 '21 21:02 martskins