2022-11-25 12:03:22 +08:00
|
|
|
local lsp_installer = require("nvim-lsp-installer")
|
2022-11-23 13:16:46 +08:00
|
|
|
|
|
|
|
-- 安装列表
|
|
|
|
-- { key: 语言 value: 配置文件 }
|
2022-11-25 12:03:22 +08:00
|
|
|
-- key 必须为下列网址列出的名称
|
|
|
|
-- https://github.com/williamboman/nvim-lsp-installer#available-lsps
|
2022-11-23 13:16:46 +08:00
|
|
|
local servers = {
|
2022-11-25 12:03:22 +08:00
|
|
|
sumneko_lua = require("lsp.config.lua"), -- lua/lsp/config/lua.lua
|
|
|
|
clangd = require("lsp.config.lua"),
|
2022-11-23 13:16:46 +08:00
|
|
|
}
|
2022-11-25 12:03:22 +08:00
|
|
|
-- 自动安装 Language Servers
|
2022-11-23 13:16:46 +08:00
|
|
|
for name, _ in pairs(servers) do
|
|
|
|
local server_is_found, server = lsp_installer.get_server(name)
|
|
|
|
if server_is_found then
|
|
|
|
if not server:is_installed() then
|
|
|
|
print("Installing " .. name)
|
|
|
|
server:install()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
lsp_installer.on_server_ready(function(server)
|
2022-11-25 12:03:22 +08:00
|
|
|
local config = servers[server.name]
|
|
|
|
if config == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if config.on_setup then
|
|
|
|
config.on_setup(server)
|
|
|
|
else
|
|
|
|
server:setup({})
|
2022-11-23 13:16:46 +08:00
|
|
|
end
|
|
|
|
end)
|