refactor(nvim): Use new lsp installer format for lspconfig

This commit is contained in:
Price Hiller 2022-05-03 20:57:45 -05:00
parent d96a6be22d
commit 9306815e60

View File

@ -1,14 +1,18 @@
local lsp_installer = require("nvim-lsp-installer")
local lspconfig = require("lspconfig")
local async = require("plenary.async")
-- NOTE: Keep this near top
lsp_installer.setup({})
local required_servers = {
"sumneko_lua",
"rust_analyzer",
"bashls",
"eslint",
"dockerls",
"ansiblels",
"tsserver"
"ansiblels",
"tsserver",
}
for _, name in pairs(required_servers) do
@ -33,77 +37,81 @@ local function on_attach(client, bufnr)
end)
end
lsp_installer.on_server_ready(function(server)
local opts = {
-- Coq configuration, ensure coq actual has capabilties shown
-- capabilities = require("coq").lsp_ensure_capabilities(vim.lsp.protocol.make_client_capabilities()),
capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()),
on_attach = on_attach,
}
local opts = {
-- Coq configuration, ensure coq actual has capabilties shown
-- capabilities = require("coq").lsp_ensure_capabilities(vim.lsp.protocol.make_client_capabilities()),
capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()),
on_attach = on_attach,
}
-- In the scenario we're using rust it makes more sense to use rust-tools
-- see: https://github.com/williamboman/nvim-lsp-installer/wiki/Rust
--
-- NOTE: Requires rust_analyzer
if server.name == "rust_analyzer" then
-- Dap installation, required vscode and the following extension to be installed:
-- https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
--
-- locate it with `find ~/ -name `
local extension_path = os.getenv("HOME") .. "/.vscode/extensions/vadimcn.vscode-lldb-1.6.10/"
local codelldb_path = extension_path .. "adapter/codelldb"
local liblldb_path = extension_path .. "lldb/lib/liblldb.dylib"
-- INFO: RUST LSP
-- In the scenario we're using rust it makes more sense to use rust-tools
-- see: https://github.com/williamboman/nvim-lsp-installer/wiki/Rust
--
-- NOTE: Requires rust_analyzer
--
-- Dap installation, required vscode and the following extension to be installed:
-- https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
--
-- locate it with `find ~/ -name `
local extension_path = os.getenv("HOME") .. "/.vscode/extensions/vadimcn.vscode-lldb-1.6.10/"
local codelldb_path = extension_path .. "adapter/codelldb"
local liblldb_path = extension_path .. "lldb/lib/liblldb.dylib"
local rustopts = {
server = vim.tbl_deep_extend("force", server:get_default_options(), opts, {}),
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
local rustopts = {
server = opts,
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
},
tools = {
hover_actions = { auto_focus = true },
},
}
require("rust-tools").setup(rustopts)
-- NOTE: ANSIBLE LSP
-- I use ansible a lot, define exceptions for servers that can use
-- server:setup & vim.cmd at the bottom here
lspconfig.ansiblels.setup({
ansible = {
ansible = {
useFullyQualifiedCollectionNames = true,
path = "ansible",
},
ansibleLint = {
enabled = true,
path = "ansible-lint",
},
python = {
interpreterPath = "python3",
},
},
})
-- NOTE: BASH LSP
lspconfig.bashls.setup({
filetypes = {
"zsh",
"bash",
"profile",
},
opts
})
-- NOTE: PYTHON LSP
lspconfig.pylsp.setup({
pylsp = {
plugins = {
pycodestyle = {
enabled = false,
},
tools = {
hover_actions = { auto_focus = true },
},
}
require("rust-tools").setup(rustopts)
server:attach_buffers()
else
-- I use ansible a lot, define exceptions for servers that can use
-- server:setup & vim.cmd at the bottom here
if server.name == "ansiblels" then
opts.settings = {
ansible = {
ansible = {
useFullyQualifiedCollectionNames = true,
path = "ansible",
},
ansibleLint = {
enabled = true,
path = "ansible-lint",
},
python = {
interpreterPath = "python3",
},
},
}
elseif server.name == "bashls" then
opts.settings = {
filetypes = {
"zsh",
"bash",
"profile",
},
}
elseif server.name == "pylsp" then
opts.settings = {
pylsp = {
plugins = {
pycodestyle = {
enabled = false
}
}
}
}
end
server:setup(opts)
vim.cmd([[ do User LspAttachBuffers ]])
end
end)
},
},
opts
})
-- NOTE: GENERIC LSP SERVERS
for _, server in ipairs {"tsserver", "eslint", "dockerls", "sumneko_lua"} do
lspconfig[server].setup(opts)
end