vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Improve workflow for enabling/disabling semantic tokens

Open findleyr opened this issue 4 months ago • 4 comments

Right now, to enable semantic tokens with gopls, it is required to set "gopls": { "semanticTokens": true }. Without this setting, gopls will return empty responses to semanticTokens requests (previously it returned an error, which led to the very verbose logs reported in golang/go#65712).

This is a bit backward: if gopls advertises the semanticTokens capability, and an LSP client requests semanticTokens, gopls should provide semanticTokens as best it can. If clients don't want semanticTokens, they should not request them.

We'd like to fix this by changing the default value of the hidden "semanticTokens" setting in gopls to "true". After this change, gopls will behave as expected by default: if clients ask for semantic tokens, they will get them.

However, if we make this change to gopls, it will implicitly enable semantic token for all VS Code users. This is a very large and observable change, and it is likely that many users will not want this behavior. For example, I personally do not want semantic tokens as I find them to be visually distracting.

We should update vscode-go so that users will still opt-in to semantic tokens, even after this gopls change. Should we change the default behavior of the VS Code LSP client to not request semantic tokens? Should we inject {"semanticTokens": false} into the vscode-go LSP settings, if it is unset?

CC @hyangah

findleyr avatar Apr 16 '24 19:04 findleyr