diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index b5b6e0f..d4cc69d 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -19,6 +19,7 @@ require("lazy").setup({ { "LazyVim/LazyVim", import = "lazyvim.plugins" }, { import = "plugins" }, { import = "plugins.langs.python" }, + { import = "plugins.langs.go" }, }, defaults = { -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index 2b9a083..45be7ae 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -5,6 +5,7 @@ return { -- python = { "ruff" }, python = { "black" }, javascript = { "biome" }, + go = {'goimports', 'gofumpt'} }, }, dependencies = { diff --git a/lua/plugins/langs/go/nvim-lspconfig.lua b/lua/plugins/langs/go/nvim-lspconfig.lua new file mode 100644 index 0000000..b7957fb --- /dev/null +++ b/lua/plugins/langs/go/nvim-lspconfig.lua @@ -0,0 +1,64 @@ +return { + "neovim/nvim-lspconfig", + opts = { + servers = { + gopls = { + settings = { + gopls = { + gofumpt = true, + codelenses = { + gc_details = false, + generate = true, + regenerate_cgo = true, + run_govulncheck = true, + test = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + analyses = { + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + usePlaceholders = true, + completeUnimported = true, + staticcheck = true, + directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, + semanticTokens = true, + }, + }, + }, + }, + setup = { + gopls = function(_, opts) + -- workaround for gopls not supporting semanticTokensProvider + -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 + LazyVim.lsp.on_attach(function(client, _) + if not client.server_capabilities.semanticTokensProvider then + local semantic = client.config.capabilities.textDocument.semanticTokens + client.server_capabilities.semanticTokensProvider = { + full = true, + legend = { + tokenTypes = semantic.tokenTypes, + tokenModifiers = semantic.tokenModifiers, + }, + range = true, + } + end + end, "gopls") + -- end workaround + end, + }, + }, +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index 7eebbb8..3a2d103 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -2,15 +2,23 @@ return { "williamboman/mason.nvim", opts = { ensure_installed = { + -- python "basedpyright", - "biome", - "black", - "lemminx", - "lua-language-server", - "ruby-lsp", "ruff", - "shfmt", + -- js, json, xml, all front end stuff + "black", + "biome", + "lemminx", + -- lua "stylua", + "lua-language-server", + --ruby + "ruby-lsp", + -- bash + "shfmt", + -- go + "goimports", + "gofumpt" }, }, } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 71aa423..7782bea 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -22,7 +22,12 @@ return { "json", "html", -- - "ruby" + "ruby", + -- + "go", + "gomod", + "gowork", + "gosum", }, }, },