144 lines
3.0 KiB
Lua
144 lines
3.0 KiB
Lua
local status_ok, mason = pcall(require, "mason")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
local status_ok_1, mason_lspconfig = pcall(require, "mason-lspconfig")
|
|
if not status_ok_1 then
|
|
return
|
|
end
|
|
|
|
local servers = {
|
|
"cssls",
|
|
"cssmodules_ls",
|
|
"emmet_ls",
|
|
"html",
|
|
"jdtls",
|
|
"solc",
|
|
"solidity_ls",
|
|
"sumneko_lua",
|
|
"omnisharp",
|
|
"tflint",
|
|
"terraformls",
|
|
"tsserver",
|
|
"pyright",
|
|
"yamlls",
|
|
"bashls",
|
|
"clangd",
|
|
"rust_analyzer",
|
|
"taplo",
|
|
"zk@v0.10.1",
|
|
"lemminx",
|
|
"clangd",
|
|
}
|
|
|
|
local settings = {
|
|
ui = {
|
|
border = "rounded",
|
|
icons = {
|
|
package_installed = "◍",
|
|
package_pending = "◍",
|
|
package_uninstalled = "◍",
|
|
},
|
|
},
|
|
log_level = vim.log.levels.INFO,
|
|
max_concurrent_installers = 4,
|
|
}
|
|
|
|
mason.setup(settings)
|
|
mason_lspconfig.setup({
|
|
ensure_installed = servers,
|
|
automatic_installation = true,
|
|
})
|
|
|
|
local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
|
|
if not lspconfig_status_ok then
|
|
print("lspconfig error!")
|
|
return
|
|
end
|
|
|
|
local opts = {}
|
|
|
|
for _, server in pairs(servers) do
|
|
opts = {
|
|
on_attach = require("user.lsp.handlers").on_attach,
|
|
capabilities = require("user.lsp.handlers").capabilities,
|
|
}
|
|
|
|
server = vim.split(server, "@")[1]
|
|
|
|
if server == "yamlls" then
|
|
local yamlls_opts = require("user.lsp.settings.yamlls")
|
|
opts = vim.tbl_deep_extend("force", yamlls_opts, opts)
|
|
end
|
|
|
|
if server == "sumneko_lua" then
|
|
local l_status_ok, lua_dev = pcall(require, "lua-dev")
|
|
if not l_status_ok then
|
|
return
|
|
end
|
|
local luadev = lua_dev.setup({
|
|
lspconfig = {
|
|
on_attach = opts.on_attach,
|
|
capabilities = opts.capabilities,
|
|
},
|
|
})
|
|
lspconfig.sumneko_lua.setup(luadev)
|
|
goto continue
|
|
end
|
|
|
|
if server == "tsserver" then
|
|
local tsserver_opts = require("user.lsp.settings.tsserver")
|
|
opts = vim.tbl_deep_extend("force", tsserver_opts, opts)
|
|
end
|
|
|
|
if server == "pyright" then
|
|
local pyright_opts = require("user.lsp.settings.pyright")
|
|
opts = vim.tbl_deep_extend("force", pyright_opts, opts)
|
|
end
|
|
|
|
if server == "solc" then
|
|
local solc_opts = require("user.lsp.settings.solc")
|
|
opts = vim.tbl_deep_extend("force", solc_opts, opts)
|
|
end
|
|
|
|
if server == "clangd" then
|
|
local clangd_opts = require("user.lsp.settings.clangd")
|
|
opts = vim.tbl_deep_extend("force", clangd_opts, opts)
|
|
end
|
|
|
|
if server == "emmet_ls" then
|
|
local emmet_ls_opts = require("user.lsp.settings.emmet_ls")
|
|
opts = vim.tbl_deep_extend("force", emmet_ls_opts, opts)
|
|
end
|
|
|
|
if server == "zk" then
|
|
local zk_opts = require("user.lsp.settings.zk")
|
|
opts = vim.tbl_deep_extend("force", zk_opts, opts)
|
|
end
|
|
|
|
if server == "jdtls" then
|
|
goto continue
|
|
end
|
|
|
|
if server == "rust_analyzer" then
|
|
local rust_opts = require("user.lsp.settings.rust")
|
|
-- opts = vim.tbl_deep_extend("force", rust_opts, opts)
|
|
local rust_tools_status_ok, rust_tools = pcall(require, "rust-tools")
|
|
if not rust_tools_status_ok then
|
|
return
|
|
end
|
|
|
|
rust_tools.setup(rust_opts)
|
|
goto continue
|
|
end
|
|
|
|
if server == "omnisharp" then
|
|
local omnisharp_opts = require("user.lsp.settings.omnisharp")
|
|
opts = vim.tbl_deep_extend("force", omnisharp_opts, opts)
|
|
end
|
|
|
|
lspconfig[server].setup(opts)
|
|
::continue::
|
|
end
|