Add support for code highlighting using semantic tokens #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "semantic-tokens"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This adds support for highlighting using LSP semantic tokens. This feature must be enabled manually by implementing
LSPClientConfig.highlightSemanticTokenswhich is where to specify how semantic tokens should be translated to codemirror decorations.Updates are debounced to avoid requesting semantic tokens on every text edit and could also support client side cancellation in theory (more on that in the code comment). The implementation only really supports
textDocument/semanticTokens/fullbut will fall back to requestingtextDocument/semanticTokens/rangeon the entire document if unavailable.@ -0,0 +38,4 @@startRequest(plugin: LSPPlugin, view: EditorView): void {if (this.pendingRequest != null) {// There is a pending request on an older document state that should// be cancelled here.This is where there should be a call to
plugin.client.cancelRequestbut I encountered an issue while trying to do that.cancelRequestidentifies requests based on the params using JS object equality which seems unusual. Is there are particular reason why it doesn't use the request id? The only usage of this function is for code completions so perhaps it could be reworked to use the id instead of params.The
cancelRequestimplementation is also kind of broken. See #3Hi. I'm not interested in including support for semantic tokens in this package. They aren't a great fit in CodeMirror—client-side parsing is more responsive, and allows other extensions to also use the tree. I think it should be possible to implement this outside of this repository using the package's API (if not, feel free to open an issue about the problems you run into), so you could consider distributing it yourself as a separate package.
Pull request closed