-
-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Description
I am having trouble integrating go.nvim into my setup. I see errors when opening a go file, and editing is very erratic and close to unusable.
I am assuming I am configuring something wrong, so I assume it's on my end.
As soon as I open a go file, I see an error at the bottom:
LSP[gopls] Invalid settings: setting option "analyses": the 'fieldalignment' analyzer was removed in gopls/v0.17.0; instead, hover over struct fields to see size/offset information (https://go.dev/issue/66861); setting option "noSemanticString"; noSemanticString setting is deprecated, use semanticTokenTypes instead (though you can continue to apply them for the time being).
Press ENTER or type command to continue
which is odd, as if I check what the configs are for gopls from go.nvim as per the docs, there isn't any noSemanticString, for example, and fieldalignment
is set to false
.
Anyways, if I then hit enter, I see:
Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:304: /usr/share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:82: table index is nil
stack traceback:
[builtin#36]: at 0x7e8b982ae560
/usr/share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:304: in function 'handler'
/usr/share/nvim/runtime/lua/vim/lsp/client.lua:687: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
and from there it's downwards, as on editing the above stack trace appears constantly, and it becomes a nightmare.
I hope someone can help.
> gopls version
golang.org/x/tools/gopls v0.18.1
checkhealth go
doesn't report a whole lot:
go: require("go.health").check()
Binaries ~
- go installed.
- Tool installed: gorename
- Tool installed: gotestsum
- Tool installed: guru
- Tool installed: ginkgo
- Tool installed: callgraph
- Tool installed: iferr
- Tool installed: fillswitch
- Tool installed: golangci-lint
- Tool installed: golines
- Tool installed: dlv
- Tool installed: govulncheck
- Tool installed: richgo
- Tool installed: gopls
- Tool installed: impl
- Tool installed: gomvp
- Tool installed: mockgen
- Tool installed: goimports
- Tool installed: json-to-struct
- Tool installed: gonew
- Tool installed: go-enum
- Tool installed: gofumpt
- Tool installed: gomodifytags
- Tool installed: gotests
- Tool installed: fillstruct
- sed installed.
- curl installed.
- OK All binaries installed
Go Plugin Check ~
- OK lspconfig: plugin is installed
- OK nvim-treesitter: plugin is installed
- OK guihua: plugin is installed
- WARNING nvim-dap-virtual-text: not installed/loaded
- OK telescope: plugin is installed
- OK nvim-treesitter-go is installed
- WARNING nvim-dap: not installed/loaded
- WARNING nvim-dap-ui: not installed/loaded
- WARNING Not all plugin installed
- OK GOROOT is set
- GOBIN is not set
- Not all environment variables set
- WARNING GOBIN is not in PATH
#init.lua:
require("plugins")
-- Mason Setup
require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
}
}
})
require("mason-lspconfig").setup()
require("vimspector")
require("golang")
#plugins.lua:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git", "clone", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release
lazypath
})
end
vim.opt.rtp:prepend(lazypath)
local plugins = {
-- other plugin initializations, should not be relevant, but I can post if required
{
"ray-x/go.nvim",
dependencies = { -- optional packages
"ray-x/guihua.lua", "neovim/nvim-lspconfig",
"nvim-treesitter/nvim-treesitter"
},
-- ---> disabled this because I configure it in golang.lua, or so I thought it's required to do the lsp_cfg as per the docs... <-----
-- config = function()
-- require("go").setup()
-- end,
event = { "CmdlineEnter" },
ft = { "go", 'gomod' },
build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries
}, -- python stuff
--- other stuff
}
local opts = {}
require("lazy").setup(plugins, opts)
#golang.lua:
local format_sync_grp = vim.api.nvim_create_augroup("goimports", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function() require('go.format').goimports() end,
group = format_sync_grp
})
require('go').setup {
lsp_cfg = false
-- other setups...
}
local cfg = require 'go.lsp'.config() -- config() return the go.nvim gopls setup
require('lspconfig').gopls.setup(cfg)
anlakii
Metadata
Metadata
Assignees
Labels
No labels