This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmason.lua
98 lines (88 loc) · 2.62 KB
/
mason.lua
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
-- https://github.com/williamboman/mason.nvim
-- https://github.com/williamboman/mason-lspconfig.nvim/blob/main/doc/server-mapping.md
---@diagnostic disable: param-type-mismatch
local options = require("core.options")
local M = {
requires = {
"mason",
"mason-registry",
},
}
function M.before()
M.installer_tools = {
lsp = {
"gopls",
"clangd",
"pyright",
"css-lsp",
"json-lsp",
"html-lsp",
"emmet-ls",
"vetur-vls",
-- "rust-analyzer",
"vim-language-server",
"lua-language-server",
"bash-language-server",
"typescript-language-server",
"tailwindcss-language-server",
},
dap = {
"delve",
"debugpy",
"cpptools",
},
linter = {
"pylint",
},
formatter = {
"shfmt",
"autopep8",
"prettier",
"clang-format",
"sql-formatter",
"stylua",
"fixjson",
},
}
end
function M.load()
M.mason.setup({
max_concurrent_installers = 20,
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
border = options.float_border and "double" or "none",
},
install_root_dir = options.mason_install_directory,
})
end
function M.after()
local installed_packages = {}
for _, package_kind in pairs(M.installer_tools) do
for _, package_name_version in pairs(package_kind) do
---@diagnostic disable-next-line: missing-parameter
local name, version = unpack(vim.split(package_name_version, "@"))
if not M.mason_registry.is_installed(name) then
if not M.mason_registry.has_package(name) then
vim.notify(("Invalid package name : %s"):format(name), "ERROR", { title = "Mason" })
else
local params = version and { version = version }
M.mason_registry.get_package(name):install(params)
table.insert(installed_packages, package_name_version)
end
end
end
end
if not vim.tbl_isempty(installed_packages) then
vim.notify(
("Start install package : \n - %s"):format(table.concat(installed_packages, "\n - ")),
"INFO",
{ title = "Mason" }
)
end
end
return M