Split mason configs
This commit is contained in:
parent
644edc8b2e
commit
f8ad93746b
8
nvim/dot-config/nvim/lua/plugins/mason-lspconfig.lua
Normal file
8
nvim/dot-config/nvim/lua/plugins/mason-lspconfig.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
opts = {},
|
||||
dependencies = {
|
||||
"mason-org/mason.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
}
|
86
nvim/dot-config/nvim/lua/plugins/mason-tool-installer.lua
Normal file
86
nvim/dot-config/nvim/lua/plugins/mason-tool-installer.lua
Normal file
|
@ -0,0 +1,86 @@
|
|||
return {
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
dependencies = {
|
||||
"mason-org/mason.nvim",
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
"zapling/mason-conform.nvim",
|
||||
},
|
||||
config = function()
|
||||
local lsp = require("tools.lsp")
|
||||
|
||||
-- Convert lsp entries to consistent format
|
||||
local tools = {}
|
||||
for _, tool in pairs(lsp) do
|
||||
if type(tool) == "table" then
|
||||
local name = tool[1]
|
||||
local entry = {}
|
||||
|
||||
-- Make a copy and strip out name and lsp config
|
||||
for k, v in pairs(tool) do
|
||||
if k ~= 1 and k ~= 2 then
|
||||
entry[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
tools[name] = entry
|
||||
else
|
||||
tools[tool] = {}
|
||||
end
|
||||
end
|
||||
|
||||
-- Convert formatters to same format and merge on top of the lsps
|
||||
local formatters_by_ft = require("conform").formatters_by_ft
|
||||
local mapping = require("mason-conform.mapping")
|
||||
for _, formatter in pairs(formatters_by_ft) do
|
||||
if type(formatter) == "table" then
|
||||
for _, tool in ipairs(formatter) do
|
||||
local entry = {}
|
||||
local name = nil
|
||||
if type(tool) == "table" then
|
||||
name = mapping.conform_to_package[tool[1]]
|
||||
|
||||
-- Make a copy and strip out name
|
||||
for k, v in pairs(tool) do
|
||||
if k ~= 1 then
|
||||
entry[k] = v
|
||||
end
|
||||
end
|
||||
else
|
||||
name = mapping.conform_to_package[tool]
|
||||
end
|
||||
|
||||
if name ~= nil then
|
||||
tools[name] = vim.tbl_extend("error", tools[name] or {}, entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local ensure_installed = vim.iter(tools)
|
||||
:map(function(name, tool)
|
||||
if type(tool) == "table" then
|
||||
if tool.system then
|
||||
return nil
|
||||
end
|
||||
|
||||
local entry = {
|
||||
[1] = name,
|
||||
}
|
||||
|
||||
for k, v in pairs(tool) do
|
||||
entry[k] = v
|
||||
end
|
||||
|
||||
return entry
|
||||
end
|
||||
return tool
|
||||
end)
|
||||
:totable()
|
||||
|
||||
require("mason-tool-installer").setup({
|
||||
ensure_installed = ensure_installed,
|
||||
auto_update = true,
|
||||
debounde_hours = 24,
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -1,96 +1,4 @@
|
|||
return {
|
||||
{
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
dependencies = {
|
||||
{ "mason-org/mason.nvim", opts = {} },
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
"zapling/mason-conform.nvim",
|
||||
},
|
||||
config = function()
|
||||
local lsp = require("tools.lsp")
|
||||
|
||||
-- Convert lsp entries to consistent format
|
||||
local tools = {}
|
||||
for _, tool in pairs(lsp) do
|
||||
if type(tool) == "table" then
|
||||
local name = tool[1]
|
||||
local entry = {}
|
||||
|
||||
-- Make a copy and strip out name and lsp config
|
||||
for k, v in pairs(tool) do
|
||||
if k ~= 1 and k ~= 2 then
|
||||
entry[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
tools[name] = entry
|
||||
else
|
||||
tools[tool] = {}
|
||||
end
|
||||
end
|
||||
|
||||
-- Convert formatters to same format and merge on top of the lsps
|
||||
local formatters_by_ft = require("conform").formatters_by_ft
|
||||
local mapping = require("mason-conform.mapping")
|
||||
for _, formatter in pairs(formatters_by_ft) do
|
||||
if type(formatter) == "table" then
|
||||
for _, tool in ipairs(formatter) do
|
||||
local entry = {}
|
||||
local name = nil
|
||||
if type(tool) == "table" then
|
||||
name = mapping.conform_to_package[tool[1]]
|
||||
|
||||
-- Make a copy and strip out name
|
||||
for k, v in pairs(tool) do
|
||||
if k ~= 1 then
|
||||
entry[k] = v
|
||||
end
|
||||
end
|
||||
else
|
||||
name = mapping.conform_to_package[tool]
|
||||
end
|
||||
|
||||
if name ~= nil then
|
||||
tools[name] = vim.tbl_extend("error", tools[name] or {}, entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local ensure_installed = vim.iter(tools)
|
||||
:map(function(name, tool)
|
||||
if type(tool) == "table" then
|
||||
if tool.system then
|
||||
return nil
|
||||
end
|
||||
|
||||
local entry = {
|
||||
[1] = name,
|
||||
}
|
||||
|
||||
for k, v in pairs(tool) do
|
||||
entry[k] = v
|
||||
end
|
||||
|
||||
return entry
|
||||
end
|
||||
return tool
|
||||
end)
|
||||
:totable()
|
||||
|
||||
require("mason-tool-installer").setup({
|
||||
ensure_installed = ensure_installed,
|
||||
auto_update = true,
|
||||
debounde_hours = 24,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
"mason-org/mason.nvim",
|
||||
opts = {},
|
||||
dependencies = {
|
||||
{ "mason-org/mason.nvim", opts = {} },
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user