nimlsp icon indicating copy to clipboard operation
nimlsp copied to clipboard

Support for semantic highlighting

Open alaviss opened this issue 5 years ago • 6 comments

nimsuggest already has powerful highlighting capability via the highlight command. I'd like to see this exposed via the LSP interface.

The current proposal for semantic highlighting in LSP (https://github.com/microsoft/language-server-protocol/issues/18) doesn't seem to reach a conclusion yet, so I'd propose that we implement a server-specific method for this (maybe nimlsp/semanticHighlight?, I'm not sure how vendor-specific methods are done).

For simplicity we just need an array containing these information for a given file:

  • Token type (we can just emit the native SymbolKind here)
  • Line, col
  • Length of token

The upcoming major version of neovim will feature a scriptable LSP interface that I can use to do custom queries like this, allowing me to deprecate the current nimsuggest processing code in nim.nvim.

alaviss avatar May 13 '20 03:05 alaviss

I have already started implementing the proposal. Building our own version is directly against the entire purpose of LSP as it would only work with Nim-aware LSP clients. I know that at least the Vim language server has implemented the proposed version.

PMunch avatar May 13 '20 08:05 PMunch

The community seems to still be debating whether that's the right way to implement semantic highlighting. So I'm just proposing a way for us to have this function before the semantic highlighting extension for LSP is finalized.

alaviss avatar May 13 '20 08:05 alaviss

I think the only thing possibly up for discussion (might be in part my fault :scream: ) is the token edits part, which is optional and skipped by various real-world LSP servers anyway. If any of you got input on this though, head over and jump in: https://github.com/microsoft/language-server-protocol/issues/18

ghost avatar May 14 '20 21:05 ghost

I figured the basics were already fairly agreed upon as editors like Vim have already started adding support for it. This is the PR I'm using as my reference for what I'm implementing, which should be the same as what is supported in Vim: https://github.com/microsoft/vscode-languageserver-node/pull/367/files

PMunch avatar May 14 '20 21:05 PMunch

@PMunch are you still working on this?

ed-aka-yaboi avatar Jan 28 '22 02:01 ed-aka-yaboi

I haven't abandoned it if that is what you're asking. But I haven't actively worked on it for a while.

PMunch avatar Jan 28 '22 07:01 PMunch