2022-05-06 20:44:22 -05:00
|
|
|
local lsp_installer = require('nvim-lsp-installer')
|
|
|
|
local lspconfig = require('lspconfig')
|
|
|
|
local async = require('plenary.async')
|
2022-01-15 19:15:09 -06:00
|
|
|
|
2022-05-03 20:57:45 -05:00
|
|
|
-- NOTE: Keep this near top
|
|
|
|
lsp_installer.setup({})
|
|
|
|
|
2022-01-15 19:31:10 -06:00
|
|
|
local required_servers = {
|
2022-05-06 20:44:22 -05:00
|
|
|
'sumneko_lua',
|
|
|
|
'rust_analyzer',
|
|
|
|
'bashls',
|
|
|
|
'eslint',
|
|
|
|
'dockerls',
|
|
|
|
'ansiblels',
|
|
|
|
'tsserver',
|
|
|
|
'yamlls',
|
|
|
|
'jdtls',
|
2022-05-08 21:02:25 -05:00
|
|
|
'pylsp',
|
2022-05-06 20:44:22 -05:00
|
|
|
'html',
|
2022-05-08 22:10:24 -05:00
|
|
|
'vimls',
|
2022-05-09 21:30:51 -05:00
|
|
|
'clangd',
|
2022-05-11 21:00:57 -05:00
|
|
|
'omnisharp',
|
2022-05-15 22:29:18 -05:00
|
|
|
'sqls',
|
2022-05-19 08:58:39 -05:00
|
|
|
'yamlls',
|
|
|
|
'terraformls',
|
|
|
|
'tflint',
|
2022-01-15 19:31:10 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, name in pairs(required_servers) do
|
2022-05-06 16:52:44 -05:00
|
|
|
local server_is_found, server = lsp_installer.get_server(name)
|
|
|
|
if server_is_found then
|
|
|
|
if not server:is_installed() then
|
|
|
|
async.run(function()
|
2022-05-06 20:44:22 -05:00
|
|
|
vim.notify.async('Installing Language Server ' .. name, 'info', {
|
|
|
|
title = 'Lsp Installer',
|
2022-05-06 16:52:44 -05:00
|
|
|
})
|
|
|
|
end)
|
|
|
|
server:install()
|
|
|
|
end
|
|
|
|
end
|
2022-01-15 19:31:10 -06:00
|
|
|
end
|
|
|
|
|
2022-01-15 19:15:09 -06:00
|
|
|
local function on_attach(client, bufnr)
|
2022-05-06 16:52:44 -05:00
|
|
|
async.run(function()
|
2022-05-06 20:44:22 -05:00
|
|
|
vim.notify.async('Attached server ' .. client.name, 'info', {
|
|
|
|
title = 'Lsp Attach',
|
2022-05-06 16:52:44 -05:00
|
|
|
}).events.close()
|
|
|
|
end)
|
2022-01-15 19:31:10 -06:00
|
|
|
end
|
2022-01-15 19:15:09 -06:00
|
|
|
|
2022-05-09 21:30:51 -05:00
|
|
|
local lsp_capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
2022-05-03 20:57:45 -05:00
|
|
|
local opts = {
|
2022-05-09 21:30:51 -05:00
|
|
|
capabilities = lsp_capabilities,
|
2022-05-06 16:52:44 -05:00
|
|
|
on_attach = on_attach,
|
2022-05-03 20:57:45 -05:00
|
|
|
}
|
2022-01-08 15:24:29 -06:00
|
|
|
|
2022-05-03 20:57:45 -05:00
|
|
|
-- 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 `
|
2022-05-06 20:44:22 -05:00
|
|
|
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'
|
2022-01-25 22:01:42 -06:00
|
|
|
|
2022-05-03 20:57:45 -05:00
|
|
|
local rustopts = {
|
2022-05-06 16:52:44 -05:00
|
|
|
server = opts,
|
|
|
|
dap = {
|
2022-05-06 20:44:22 -05:00
|
|
|
adapter = require('rust-tools.dap').get_codelldb_adapter(codelldb_path, liblldb_path),
|
2022-05-06 16:52:44 -05:00
|
|
|
},
|
|
|
|
tools = {
|
|
|
|
hover_actions = { auto_focus = true },
|
|
|
|
},
|
2022-05-03 20:57:45 -05:00
|
|
|
}
|
2022-05-06 20:44:22 -05:00
|
|
|
require('rust-tools').setup(rustopts)
|
2022-05-03 20:57:45 -05:00
|
|
|
|
|
|
|
-- 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({
|
2022-05-06 16:52:44 -05:00
|
|
|
ansible = {
|
|
|
|
ansible = {
|
|
|
|
useFullyQualifiedCollectionNames = true,
|
2022-05-06 20:44:22 -05:00
|
|
|
path = 'ansible',
|
2022-05-06 16:52:44 -05:00
|
|
|
},
|
|
|
|
ansibleLint = {
|
|
|
|
enabled = true,
|
2022-05-06 20:44:22 -05:00
|
|
|
path = 'ansible-lint',
|
2022-05-06 16:52:44 -05:00
|
|
|
},
|
|
|
|
python = {
|
2022-05-06 20:44:22 -05:00
|
|
|
interpreterPath = 'python3',
|
2022-05-06 16:52:44 -05:00
|
|
|
},
|
|
|
|
},
|
2022-05-03 20:57:45 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
-- NOTE: BASH LSP
|
|
|
|
lspconfig.bashls.setup({
|
2022-05-06 16:52:44 -05:00
|
|
|
filetypes = {
|
2022-05-06 20:44:22 -05:00
|
|
|
'zsh',
|
|
|
|
'bash',
|
|
|
|
'sh',
|
2022-05-06 16:52:44 -05:00
|
|
|
},
|
|
|
|
opts,
|
2022-05-03 20:57:45 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
-- NOTE: PYTHON LSP
|
|
|
|
lspconfig.pylsp.setup({
|
2022-05-06 16:52:44 -05:00
|
|
|
opts,
|
2022-05-03 20:57:45 -05:00
|
|
|
})
|
|
|
|
|
2022-05-06 20:44:22 -05:00
|
|
|
local luadev = require('lua-dev').setup({
|
|
|
|
lspconfig = opts,
|
|
|
|
})
|
|
|
|
|
|
|
|
lspconfig.sumneko_lua.setup(luadev)
|
|
|
|
|
2022-05-15 22:29:18 -05:00
|
|
|
lspconfig.sqls.setup({
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
require('sqls').on_attach(client, bufnr)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2022-05-03 20:57:45 -05:00
|
|
|
-- NOTE: GENERIC LSP SERVERS
|
2022-05-03 21:05:19 -05:00
|
|
|
for _, server in ipairs({
|
2022-05-06 20:44:22 -05:00
|
|
|
'tsserver',
|
|
|
|
'eslint',
|
|
|
|
'dockerls',
|
|
|
|
'yamlls',
|
|
|
|
'kotlin_language_server',
|
|
|
|
'jdtls',
|
|
|
|
'vuels',
|
|
|
|
'html',
|
|
|
|
'vimls',
|
|
|
|
'clangd',
|
|
|
|
'cmake',
|
2022-05-11 21:00:57 -05:00
|
|
|
'omnisharp',
|
2022-05-19 08:58:39 -05:00
|
|
|
'yamlls',
|
|
|
|
'terraformls',
|
|
|
|
'tflint',
|
2022-05-06 20:44:22 -05:00
|
|
|
}) do
|
2022-05-06 16:52:44 -05:00
|
|
|
lspconfig[server].setup(opts)
|
2022-05-03 20:57:45 -05:00
|
|
|
end
|