Open westernwontons opened 1 year ago
After upgrading to neovim 10, my custom gopls configuration through lspconfig has stopped working. It seems that enable/disable is supported, but disable on go.nvim for inlay hints means that I can't update them with lspconfig.
https://github.com/ray-x/go.nvim/blob/master/lua/go/gopls.lua#L433
I'm using the following to configure the server.
require("lspconfig").gopls.setup(require("user.lsp.settings.gopls"))
@zalegrala Maybe
require("lspconfig").gopls.setup(require('go.lsp').config())
Hmm, that seems to still leave in place all the inlay hints, but what I'd like is to be able to turn off certain ones using the gopls
config with lspconfig.
For context, the lua/user/lsp/settings/gopls.lua
contains the following, which you can see some of the hints are disabled.
local opts = {
settings = {
gopls = {
-- buildFlags = { "-tags=requires_docker" }, -- custom build flags
experimentalPostfixCompletions = true,
analyses = {
fieldalignment = true,
-- nilness = true, -- default on
shadow = true,
-- unusedparams = true, -- default on
unusedvariable = true,
-- unusedwrite = true, -- default on
useany = true,
},
staticcheck = true,
semanticTokens = true,
codelenses = {
gc_details = true,
upgrade_dependency = true,
run_govulncheck = true,
tidy = true,
vendor = true,
test = true,
},
hints = {
assignVariableTypes = false,
compositeLiteralFields = false,
compositeLiteralTypes = false,
constantValues = false,
functionTypeParameters = true,
parameterNames = false,
rangeVariableTypes = false,
},
gofumpt = true,
},
},
init_options = {
usePlaceholders = true,
},
}
return opts
go.nvim side. You need to disable the lsp by setting lsp_cfg = false
@ray-x thank you that worked. First set lsp_config=false
and then the following.
require("lspconfig").gopls.setup(require("user.lsp.settings.gopls"))
I needed to skip require("lspconfig").gopls.setup(require('go.lsp').config())
it seems
This allowed me to tune the inlay hints. :+1:
On Neovim nightly the LSP native inlay hints are available now.
go.nvim
provides the following configuration for enabling/disabling inlay hints:but if it's disabled here, then it's disabled for both. I would like to have the ability to configure which to use. Currently, with AstroNvim, I have the following configuration for go.nvim:
I was able to remove the
gopls_inlay
autocmd, which allows Neovim to display the native ones. My primary motivation for going down this road is because thego.nvim
provided inlay hints are usually either stuck or remain in place after editing/deleting code.I'm curious if there's a different way to disable it or detect if the running Neovim version supports native inlay hints. With a little guidance I'd be happy to contribute.