-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/tools/gopls: Highlighting/Semantic Tokens: Gopls is not generating tokens for constants/readonly or packages/namespaces. #72880
Comments
CC @pjweinb |
This is what gopls emits when supplied (by the CLI client) the default set of token types and modifiers (which are listed at the bottom):
In other words, the first occurrence (the def) of myURL is Defaults used by CLI client:
|
Thanks @adonovan, I ran gopls from the command line on my example, and it is emitting the correct tokens and modifiers:
So this must be an issue with the nvim lsp plugin. |
I'll close this issue then. Thanks. |
I am running Neovim v0.10.4 with gopls v0.17.1.
EDIT: manually updated the gopls version installed by mason to v0.18.1 and see the same behavior.
For example, in the code below the constant "myUrl" will be highlighted as a constant when it is declared (:Inspect = @constant) but not when it is used in main() (:Inspect = @variable). My understanding is that there's supposed to be a group/modifier called @lsp.mod.readonly that gopls will mark a constant with, but this does not appear in the list returned by :highlight.
The usages of http and log are also marked as @variable.go when they're used within the two functions, except when http (or any other package) is used to specify a type like in the function signature for printStatus() or the declaration of resp in main() (:Inspect = @module). My understanding is that gopls should be marking these as "namespace", which is listed by :highlight.
I know at least some information is making it from gopls to Treesitter/the neovim highlighter; if I disable gopls, most of the coloring of things like function calls and non-builtin types goes away.
Here's my LSP configuration, should be pretty much the same as the one suggested by LazyVim. Not sure if that workaround for semantic token support is still needed, but I see the same problem with the defaults (gopls.setup({})).
The text was updated successfully, but these errors were encountered: