Guest User

Untitled

a guest
Jul 12th, 2024
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1.   {
  2.  
  3.     "williamboman/mason.nvim",
  4.     cmd = "Mason",
  5.     keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
  6.     build = ":MasonUpdate",
  7.     opts_extend = { "ensure_installed" },
  8.     opts = {
  9.       ensure_installed = {
  10.         "stylua",
  11.         "shfmt",
  12.       },
  13.     },
  14.     ---@param opts MasonSettings | {ensure_installed: string[]}
  15.     config = function(_, opts)
  16.       require("mason").setup(opts)
  17.       local mr = require("mason-registry")
  18.       mr:on("package:install:success", function()
  19.         vim.defer_fn(function()
  20.           -- trigger FileType event to possibly load this newly installed LSP server
  21.           require("lazy.core.handler.event").trigger({
  22.             event = "FileType",
  23.             buf = vim.api.nvim_get_current_buf(),
  24.           })
  25.         end, 100)
  26.       end)
  27.  
  28.       mr.refresh(function()
  29.         for _, tool in ipairs(opts.ensure_installed) do
  30.           local p = mr.get_package(tool)
  31.           if not p:is_installed() then
  32.             p:install()
  33.           end
  34.         end
  35.       end)
  36.     end,
  37.   }
Advertisement
Add Comment
Please, Sign In to add comment