Fix mason config
This commit is contained in:
parent
65eb554dc9
commit
ea2fef69b3
1 changed files with 0 additions and 68 deletions
|
@ -103,56 +103,6 @@ return {
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
|
vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
|
||||||
|
|
||||||
local servers = opts.servers
|
|
||||||
local capabilities = vim.tbl_deep_extend(
|
|
||||||
"force",
|
|
||||||
{},
|
|
||||||
vim.lsp.protocol.make_client_capabilities(),
|
|
||||||
require("cmp_nvim_lsp").default_capabilities(),
|
|
||||||
opts.capabilities or {}
|
|
||||||
)
|
|
||||||
|
|
||||||
local function setup(server)
|
|
||||||
local server_opts = vim.tbl_deep_extend("force", {
|
|
||||||
capabilities = vim.deepcopy(capabilities),
|
|
||||||
}, servers[server] or {})
|
|
||||||
|
|
||||||
if opts.setup[server] then
|
|
||||||
if opts.setup[server](server, server_opts) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
elseif opts.setup["*"] then
|
|
||||||
if opts.setup["*"](server, server_opts) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
require("lspconfig")[server].setup(server_opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get all the servers that are available thourgh mason-lspconfig
|
|
||||||
local have_mason, mlsp = pcall(require, "mason-lspconfig")
|
|
||||||
local all_mslp_servers = {}
|
|
||||||
if have_mason then
|
|
||||||
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
|
|
||||||
end
|
|
||||||
|
|
||||||
local ensure_installed = {} ---@type string[]
|
|
||||||
for server, server_opts in pairs(servers) do
|
|
||||||
if server_opts then
|
|
||||||
server_opts = server_opts == true and {} or server_opts
|
|
||||||
-- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
|
|
||||||
if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
|
|
||||||
setup(server)
|
|
||||||
else
|
|
||||||
ensure_installed[#ensure_installed + 1] = server
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if have_mason then
|
|
||||||
mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } })
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -167,24 +117,6 @@ return {
|
||||||
"lua-language-server",
|
"lua-language-server",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
---@param opts MasonSettings | {ensure_installed: string[]}
|
|
||||||
config = function(_, opts)
|
|
||||||
require("mason").setup(opts)
|
|
||||||
local mr = require("mason-registry")
|
|
||||||
local function ensure_installed()
|
|
||||||
for _, tool in ipairs(opts.ensure_installed) do
|
|
||||||
local p = mr.get_package(tool)
|
|
||||||
if not p:is_installed() then
|
|
||||||
p:install()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if mr.refresh then
|
|
||||||
mr.refresh(ensure_installed)
|
|
||||||
else
|
|
||||||
ensure_installed()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
"mfussenegger/nvim-jdtls",
|
"mfussenegger/nvim-jdtls",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue