Implement textDocument/semanticTokens (semantic highlighting) #331
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have only implemented the first handler and the protocol allows omitting the rest via capability negotiation, so we can add the other ones later.
Client always sends
textDocument/semanticTokens/full
almost immediately afterdidOpen
anddidChange
, which means that we may not have all the schema at that point.workspace/semanticTokens/refresh
would enable us to refresh tokens dynamically from the server side as we know more schema, e.g. whenterraform version
and/orterraform providers schema -json
finish. As a result not supporting this call initially may provide occasionally "flickering UX" (colours change as the user types), but the upside is that it can't be any worse than it is, because we are just enriching the highlighting and the static grammar in VSCode extension still provides the base.Testing requires hashicorp/vscode-terraform#523 on the client side.
Closes #264
Follow-up issues:
textDocument/semanticTokens
until schema is available Block responding to textDocument/semanticTokens until schema is available #343workspace/semanticTokens/refresh
Support workspace/semanticTokens/refresh #344textDocument/semanticTokens/range
Provide semantic tokens for document range #345textDocument/semanticTokens/full/delta
Provide semantic tokens for document delta #346