-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmason.lua
More file actions
64 lines (60 loc) · 2.08 KB
/
mason.lua
File metadata and controls
64 lines (60 loc) · 2.08 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---@type LazySpec
return {
-- External tool manager (language servers, DAP adapters, linters, formatters)
{
"mason-org/mason.nvim",
event = "VeryLazy",
config = function()
local formatters = {
"black", -- Python
"cmakelang", -- CMake
"gofumpt", -- Go
"goimports", -- Go
"golines", -- Go
"latexindent", -- Latex
"prettier", -- Multiple languages
"shfmt", -- Bash/sh
"stylua", -- Lua
}
local linters = {
"cmakelint", -- CMake
"mypy", -- Python
"shellcheck", -- Bash/sh
}
--- Ensures the given Mason packages are installed, installing any missing ones asynchronously
---@param tools string[] -- List of Mason package names to ensure installed
local function ensure_mason_tools_installed(tools)
local mr = require("mason-registry")
mr.refresh(function()
for _, tool in ipairs(tools) do
local ok, pkg = pcall(mr.get_package, tool)
if ok and not pkg:is_installed() then
pkg:install()
end
end
end)
end
require("mason").setup({
ui = { border = "rounded" },
})
ensure_mason_tools_installed(formatters)
ensure_mason_tools_installed(linters)
end,
},
-- Mason bridge for `nvim-lspconfig`, auto-installs language servers
{
"mason-org/mason-lspconfig.nvim",
dependencies = { "mason-org/mason.nvim", "neovim/nvim-lspconfig" },
event = "VeryLazy",
opts = function()
-- Language servers are automatically installed from `after/lsp`
-- and configured via `nvim-lspconfig` in
-- `lua/plugins/nvim-lspconfig.lua`
local servers = require("core.util").get_lsp_server_names()
return {
ensure_installed = servers,
automatic_enable = false, -- enabling is handled by `nvim-lspconfig`
}
end,
},
}