Code Highlight: highligth text on the document based on symbols
The document's symbol and used, should be highlighted, this is a process to on detect a word and if it is a keyword or a symbol, like a type or method or property.
LSP specification has a textDocument/documentHighlight
where a request based on the current position (line/character), and returning if it should be treated as DocumentHighlightKind
of Read
or Write
or Text
at a given range. Text
A textual occurrence; Read
Read-access of a symbol, like reading a variable; Write
Write-access of a symbol, like writing to a variable.
The above is not enough, we need to know if a word or part of the text should be highlighted to represent a Symbol or a variable. This can be archived by calling textDocument/completion
, so we now know what kind of item was added as selected from the list on type, but after read a file, the client should go each word an request the word type to the server, but that could require lot of resources.
There is workspace/symbol
so the client can ask if a word is a symbol or not, but again that means the client should call a request for each word found in the document. The request should be sent if the word is not a symbol defined in the document returned by textDocument/documentSymbol
and so is defined in other document or namespace.
Sourceview, can take workspace/symbol
and textDocument/documentSymbol
for symbol highlighting.