Closed youngxhui closed 1 year ago
I think it is enabled by default: https://github.com/ray-x/go.nvim/blob/fcc88590e0ad9d4f967ce61e14f2f979acb63b77/lua/go/lsp.lua#L94-L108
this is my config
code
it is not support semanticToken.
when i add config in lsp, it support semanticToken
nvim_lsp.gopls.setup({
-- other config
on_attach = {
-- other config
client.server_capabilities.semanticTokensProvider = {
full = {
delta = false
},
legend = {
-- from https://github.com/golang/tools/blob/master/gopls/internal/lsp/semantic.go#L981
tokenTypes = {
"namespace", "type", "class", "enum", "interface",
"struct", "typeParameter", "parameter", "variable", "property", "enumMember",
"event", "function", "method", "macro", "keyword", "modifier", "comment",
"string", "number", "regexp", "operator",
},
tokenModifiers = {
"declaration", "definition", "readonly", "static",
"deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary",
},
},
range = true,
}
}
})
Pushed a change for this. Could you take a look?
No effect
what is the result of : vim.lsp.get_active_clients()[1].server_capabilities.semanticTokensProvider
It should be:
{
full = true,
legend = {
tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },
tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "key
word", "modifier", "comment", "string", "number", "regexp", "operator" }
},
range = true
}
BTW, the setup was loaded when you use go.nvim on_attach
Would be helpful to print out your gopls config
e.g. The output of lua =vim.lsp.buf_get_clients()
and post the gopls setup.
what is the result of : vim.lsp.get_active_clients()[1].server_capabilities.semanticTokensProvider
It should be:
{ full = true, legend = { tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" }, tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "key word", "modifier", "comment", "string", "number", "regexp", "operator" } }, range = true }
BTW, the setup was loaded when you use go.nvim on_attach
output
:lua =vim.lsp.get_active_clients()[1].server_capabilities.semanticTokensProvider
{
full = {
delta = false
},
legend = {
tokenModifiers = { "declaration", "definition", "readonly", "static", "depre
cated", "abstract", "async", "modification", "documentation", "defaultLibrary" }
,
tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct",
"typeParameter", "parameter", "variable", "property", "enumMember", "event", "fu
nction", "method", "macro", "keyword", "modifier", "comment", "string", "number"
, "regexp", "operator" }
},
range = true
}
I checked your default config. You did not enable lsp_cfg by default. You should use this:
require('go').setup({
lsp_cfg = true -- it is false by default
})
thanks. i enable lsp_cfg = true
, nvim's semanticToken work successful.
nvim 0.9 has been released which support semantic token, but go.nvim lsp default config not support semanticToken.