]> git.rmz.io Git - dotfiles.git/commitdiff
nvim: configure mason
authorSamir Benmendil <me@rmz.io>
Sun, 17 Dec 2023 17:16:12 +0000 (17:16 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 17 Dec 2023 17:23:08 +0000 (17:23 +0000)
nvim/lua/plugins/lsp.lua

index cfb909a6b32cc12340f88e91bf4d44a5ae007210..3354f7d22a3f0005fa5a3e1b6d73cdf585794a46 100644 (file)
@@ -62,4 +62,37 @@ return {
       },
     },
   },
+
+  -- cmdline tools and lsp servers
+  {
+
+    "williamboman/mason.nvim",
+    cmd = "Mason",
+    keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
+    opts = {
+      ensure_installed = {
+        "stylua",
+        "shfmt",
+        -- "flake8",
+      },
+    },
+    ---@param opts MasonSettings | {ensure_installed: string[]}
+    config = function(_, opts)
+      require("mason").setup(opts)
+      local mr = require("mason-registry")
+      local function ensure_installed()
+        for _, tool in ipairs(opts.ensure_installed) do
+          local p = mr.get_package(tool)
+          if not p:is_installed() then
+            p:install()
+          end
+        end
+      end
+      if mr.refresh then
+        mr.refresh(ensure_installed)
+      else
+        ensure_installed()
+      end
+    end,
+  },
 }