nvim: simplify lsp setup
This commit is contained in:
parent
9caf0ffd87
commit
3d646d1024
|
@ -88,6 +88,26 @@ vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
|
|||
-- setup servers
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
-- set up language servers that don't need any special configuration
|
||||
local simple_ls = {
|
||||
['vscode-html-language-server'] = 'html',
|
||||
['vscode-css-language-server'] = 'cssls',
|
||||
['vscode-json-language-server'] = 'jsonls',
|
||||
['rust_analyzer'] = 'rust_analyzer',
|
||||
['gopls'] = 'gopls',
|
||||
['cmake-language-server'] = 'cmake',
|
||||
['yaml-language-server'] = 'yamlls',
|
||||
['docker-langserver'] = 'dockerls',
|
||||
}
|
||||
for exe,ls in pairs(simple_ls) do
|
||||
if vim.fn.executable(exe) > 0 then
|
||||
lspconfig[ls].setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if vim.fn.executable('clangd') > 0 then
|
||||
require("clangd_extensions").setup({
|
||||
server = {
|
||||
|
@ -165,41 +185,6 @@ if vim.fn.executable('lemminx') > 0 then
|
|||
})
|
||||
end
|
||||
|
||||
if vim.fn.executable('vscode-html-language-server') > 0 then
|
||||
lspconfig.html.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
})
|
||||
end
|
||||
|
||||
if vim.fn.executable('vscode-css-language-server') > 0 then
|
||||
lspconfig.cssls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
})
|
||||
end
|
||||
|
||||
if vim.fn.executable('vscode-json-language-server') > 0 then
|
||||
lspconfig.jsonls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
})
|
||||
end
|
||||
|
||||
if vim.fn.executable('rust_analyzer') > 0 then
|
||||
lspconfig.rust_analyzer.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
})
|
||||
end
|
||||
|
||||
if vim.fn.executable('gopls') > 0 then
|
||||
lspconfig.gopls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
})
|
||||
end
|
||||
|
||||
if vim.fn.glob('/usr/lib64/perl5/vendor_perl/5.*/Perl/LanguageServer.pm') ~= ''
|
||||
then
|
||||
lspconfig.perlls.setup({
|
||||
|
@ -224,13 +209,6 @@ if vim.fn.executable('bash-language-server') > 0 then
|
|||
})
|
||||
end
|
||||
|
||||
if vim.fn.executable('cmake-language-server') > 0 then
|
||||
lspconfig.cmake.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
})
|
||||
end
|
||||
|
||||
if vim.fn.executable('typescript-language-server') > 0 then
|
||||
lspconfig.tsserver.setup({
|
||||
cmd = {
|
||||
|
@ -242,20 +220,6 @@ if vim.fn.executable('typescript-language-server') > 0 then
|
|||
})
|
||||
end
|
||||
|
||||
if vim.fn.executable('yaml-language-server') > 0 then
|
||||
lspconfig.yamlls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
})
|
||||
end
|
||||
|
||||
if vim.fn.executable('docker-langserver') > 0 then
|
||||
lspconfig.dockerls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
})
|
||||
end
|
||||
|
||||
require('lsp-format').setup({
|
||||
sync = true -- seems to be needed to not interfere with Neogit
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue