Repository navigation
Expand file tree
/
Copy pathmason.lua
More file actions
47 lines (47 loc) · 1.81 KB
/
Copy pathmason.lua
File metadata and controls
47 lines (47 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-- Mason tools configuration
-- Ensures linting and formatting tools are installed
return {
"mason-org/mason.nvim",
init = function()
-- :MasonUpdateAll updates every installed package and blocks until done (for headless use)
vim.api.nvim_create_user_command("MasonUpdateAll", function()
local registry = require("mason-registry")
local pending, refreshed = 0, false
registry.refresh(function()
for _, pkg in ipairs(registry.get_installed_packages()) do
local installed = pkg:get_installed_version()
local ok, latest = pcall(pkg.get_latest_version, pkg)
if ok and latest and latest ~= installed then
print(("updating %s: %s -> %s"):format(pkg.name, installed or "?", latest))
pending = pending + 1
pkg:install({ version = latest }, function(success, err)
if not success then
io.stderr:write(("failed to update %s: %s\n"):format(pkg.name, tostring(err)))
end
pending = pending - 1
end)
end
end
refreshed = true
end)
vim.wait(900000, function()
return refreshed and pending <= 0
end, 200)
end, { desc = "Update all installed Mason packages" })
end,
opts = function(_, opts)
opts.ensure_installed = vim.tbl_filter(function(tool)
return tool ~= "ansible-lint"
end, opts.ensure_installed or {})
vim.list_extend(opts.ensure_installed, {
"debugpy", -- Python debug adapter
"harper-ls", -- Spelling and grammar checking
"nginx-language-server", -- Nginx LSP
"ruff", -- Python linting and formatting
"rumdl", -- Markdown formatting in Obsidian vaults
"rust-analyzer", -- Rust LSP
"sqlfluff", -- SQL linting and formatting
"ty", -- Python LSP
})
end,
}