call mason in a safer way, and initalize servers better
This commit is contained in:
@ -62,10 +62,25 @@ vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
|
|||||||
vim.lsp.handlers.signature_help, { border = 'shadow' })
|
vim.lsp.handlers.signature_help, { border = 'shadow' })
|
||||||
|
|
||||||
-- get servers and attach to them
|
-- get servers and attach to them
|
||||||
require('mason').setup {}
|
local status_ok1, mason = pcall(require, "mason")
|
||||||
require('mason-lspconfig').setup {}
|
if not status_ok1 then
|
||||||
|
return
|
||||||
local get_servers = require('mason-lspconfig').get_installed_servers
|
|
||||||
for _, server_name in ipairs(get_servers()) do
|
|
||||||
lspconfig[server_name].setup({ on_attach = lsp_attach, })
|
|
||||||
end
|
end
|
||||||
|
mason.setup {}
|
||||||
|
|
||||||
|
local status_ok2, masonlspconfig = pcall(require, "mason-lspconfig")
|
||||||
|
if not status_ok2 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
masonlspconfig.setup {}
|
||||||
|
masonlspconfig.setup_handlers {
|
||||||
|
function (server_name)
|
||||||
|
lspconfig[server_name].setup { on_attach = lsp_attach }
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- specific servers can be setup as follows:
|
||||||
|
-- ["rust_analyzer"] = function ()
|
||||||
|
-- require("rust-tools").setup {}
|
||||||
|
-- end
|
||||||
|
-- check out :help mason-lspconfig for more info
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user