more gopls config. add inlay hint toggle

Mon, 26 Aug 2024 14:23:43 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 26 Aug 2024 14:23:43 -0500
changeset 1177
93b5d2db30bc
parent 1176
1cb4636d6d36
child 1178
8993dc4128de

more gopls config. add inlay hint toggle

.config/nvim/lua/config/maps.lua file | annotate | diff | comparison | revisions
.config/nvim/lua/plugins/lsp.lua file | annotate | diff | comparison | revisions
--- a/.config/nvim/lua/config/maps.lua
+++ b/.config/nvim/lua/config/maps.lua
@@ -115,6 +115,10 @@ vim.api.nvim_create_autocmd("LspAttach",
       vim.lsp.buf.format({ async = true })
     end, "LSP Format")
 
+    bmap("n", "<leader>ih", function()
+      vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
+    end, "Toggle Inlay Hints")
+
     local code_actions = require("actions-preview").code_actions
     bmap("n", "crr", code_actions, "Code Actions")
     bmap("x", "<C-R><C-R>", code_actions, "Code Actions")
--- a/.config/nvim/lua/plugins/lsp.lua
+++ b/.config/nvim/lua/plugins/lsp.lua
@@ -19,7 +19,21 @@ return {
         gopls = function()
           require("lspconfig").gopls.setup({
             capabilities = capabilities,
-            settings = { gopls = { gofumpt = true } },
+            settings = {
+              gopls = {
+                analyses = {
+                  unusedvariable = true,
+                  useany = true,
+                },
+                hints = {
+                  constantValues = true,
+                  rangeVariableTypes = true,
+                },
+                vulncheck = "Imports",
+                gofumpt = true,
+                staticcheck = true,
+              },
+            },
           })
         end,
         solargraph = function()

mercurial