Added option to use system lsp instead of mason

This commit is contained in:
Dreaded_X 2024-06-28 02:07:15 +02:00
parent fdaa5e752d
commit b3e20c39c7
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
3 changed files with 26 additions and 11 deletions

View File

@ -122,16 +122,22 @@ return {
dynamicRegistration = true, dynamicRegistration = true,
} }
require("mason-lspconfig").setup({ local handler = function(server_name)
handlers = { local server = require("tools").servers[server_name] or {}
function(server_name) server.capabilities = vim.tbl_deep_extend("force", capabilities, server.capabilities or {})
local server = require("tools").servers[server_name] or {} server.handlers = handlers
server.capabilities = vim.tbl_deep_extend("force", capabilities, server.capabilities or {})
server.handlers = handlers
require("lspconfig")[server_name].setup(server) require("lspconfig")[server_name].setup(server)
end, end
},
for server, config in pairs(require("tools").servers) do
if config.system then
handler(server)
end
end
require("mason-lspconfig").setup({
handlers = { handler },
}) })
end, end,
} }

View File

@ -15,7 +15,13 @@ return {
}, },
config = function() config = function()
local tools = require("tools") local tools = require("tools")
local ensure_installed = vim.tbl_keys(tools.servers) local ensure_installed = vim.tbl_keys(vim.tbl_map(function(server)
if server.system then
return nil
else
return server
end
end, tools.servers))
ensure_installed = ensure_installed =
vim.list_extend(ensure_installed, require("util.mason").process_formatters(tools.formatters)) vim.list_extend(ensure_installed, require("util.mason").process_formatters(tools.formatters))
ensure_installed = vim.list_extend(ensure_installed, tools.extra) ensure_installed = vim.list_extend(ensure_installed, tools.extra)

View File

@ -8,6 +8,7 @@ tools.servers = {
gopls = {}, gopls = {},
pyright = {}, pyright = {},
rust_analyzer = { rust_analyzer = {
system = true,
settings = { settings = {
["rust-analyzer"] = { ["rust-analyzer"] = {
check = { check = {
@ -45,7 +46,9 @@ tools.servers = {
}, },
taplo = {}, taplo = {},
neocmake = {}, neocmake = {},
-- nil_ls = {}, nil_ls = {
system = true,
},
typos_lsp = { typos_lsp = {
init_options = { init_options = {
diagnosticSeverity = "Hint", diagnosticSeverity = "Hint",