Dot_Files/.config/nvim/lua/plugins/configs/lsp.lua

136 lines
3.2 KiB
Lua
Raw Normal View History

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
-- 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',
'csharp_ls'
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
local opts = {
2022-05-06 16:52:44 -05:00
-- Coq configuration, ensure coq actual has capabilties shown
-- capabilities = require("coq").lsp_ensure_capabilities(vim.lsp.protocol.make_client_capabilities()),
2022-05-06 20:44:22 -05:00
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
2022-05-06 16:52:44 -05:00
on_attach = on_attach,
}
2022-01-08 15:24:29 -06: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'
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-06 20:44:22 -05:00
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({
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
},
},
})
-- 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,
})
-- NOTE: PYTHON LSP
lspconfig.pylsp.setup({
2022-05-06 16:52:44 -05:00
opts,
})
2022-05-06 20:44:22 -05:00
local luadev = require('lua-dev').setup({
lspconfig = opts,
})
lspconfig.sumneko_lua.setup(luadev)
-- 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',
'ccls',
'clangd',
'cmake',
2022-05-08 22:10:24 -05:00
'csharp_ls'
2022-05-06 20:44:22 -05:00
}) do
2022-05-06 16:52:44 -05:00
lspconfig[server].setup(opts)
end