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

177 lines
5.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
2022-06-03 23:00:22 -05:00
lsp_installer.setup({
2022-06-04 18:23:46 -05:00
automatic_installation = true,
2022-06-03 23:00:22 -05:00
})
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())
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-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-27 21:54:19 -05:00
crate_graph = {
backend = 'svg',
output = 'Rust-Crate-Graph-' .. os.time() .. '.svg',
},
2022-05-06 16:52:44 -05:00
},
}
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-06-04 18:09:59 -05:00
opts,
2022-05-26 15:42:33 -05:00
settings = {
2022-05-06 16:52:44 -05:00
ansible = {
2022-05-26 15:42:33 -05:00
ansible = {
useFullyQualifiedCollectionNames = true,
path = 'ansible',
},
ansibleLint = {
enabled = true,
path = 'ansible-lint',
},
python = {
interpreterPath = 'python3',
},
2022-05-06 16:52:44 -05:00
},
},
})
2022-05-26 15:42:33 -05:00
-- NOTE: LUA LSP
2022-05-06 20:44:22 -05:00
local luadev = require('lua-dev').setup({
lspconfig = opts,
})
lspconfig.sumneko_lua.setup(luadev)
2022-05-26 15:42:33 -05:00
-- NOTE: SQL LSP
2022-05-15 22:29:18 -05:00
lspconfig.sqls.setup({
on_attach = function(client, bufnr)
require('sqls').on_attach(client, bufnr)
2022-06-04 18:09:59 -05:00
on_attach(client, bufnr)
2022-05-15 22:29:18 -05:00
end,
})
2022-05-26 15:42:33 -05:00
-- NOTE: PYTHON LSP
lspconfig.pylsp.setup({
filetypes = { 'python' },
settings = {
formatCommand = { 'black' },
pylsp = {
plugins = {
jedi_completion = {
include_params = true,
fuzzy = true,
eager = true,
},
jedi_signature_help = { enabled = true },
pyflakes = { enabled = true },
pycodestyle = {
enabled = true,
2022-06-12 23:38:14 -05:00
ignore = { 'E501', 'E231', 'W503', 'E731' },
2022-05-26 15:42:33 -05:00
maxLineLength = 120,
},
2022-06-12 23:32:45 -05:00
mypy = { enabled = true },
2022-05-26 15:42:33 -05:00
yapf = { enabled = true },
2022-06-12 23:32:45 -05:00
rope_completion = {
enabled = true,
eager = true,
},
2022-05-26 15:42:33 -05:00
},
},
},
2022-06-04 18:09:59 -05:00
capabilities = lsp_capabilities,
on_attach = on_attach,
2022-05-26 15:42:33 -05:00
})
2022-06-01 12:29:29 -05:00
lspconfig.yamlls.setup({
settings = {
yaml = {
schemas = {
['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*',
2022-06-02 20:26:57 -05:00
['https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json'] = '/azure-pipeline*.y*l',
2022-06-01 12:29:29 -05:00
['https://raw.githubusercontent.com/docker/cli/master/cli/compose/schema/data/config_schema_v3.10.json'] = '/docker-compose.y*l',
['https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json'] = '/.gitlab-ci.yml',
2022-06-01 13:53:08 -05:00
['https://json.schemastore.org/travis.json'] = '/.travis.y*l',
2022-06-10 16:24:41 -05:00
['https://raw.githubusercontent.com/ansible-community/schemas/main/f/ansible-inventory.json'] = {
'/inventories/*/*.y*l',
'/inventory/*.y*l',
},
['https://raw.githubusercontent.com/ansible-community/schemas/main/f/ansible-vars.json'] = {
'playbooks/vars/*.y*l',
'vars/*.y*l',
'defaults/*.y*l',
'host_vars/*.y*l',
'group_vars/*.y*l',
},
2022-06-01 12:29:29 -05:00
},
},
},
2022-06-04 18:09:59 -05:00
capabilities = lsp_capabilities,
on_attach = on_attach,
2022-06-01 12:29:29 -05:00
})
2022-06-01 23:35:11 -05:00
lspconfig.csharp_ls.setup({
handlers = {
['textDocument/definition'] = require('csharpls_extended').handler,
},
2022-06-04 18:09:59 -05:00
capabilities = lsp_capabilities,
on_attach = on_attach,
2022-06-01 23:35:11 -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
'clangd',
'cmake',
2022-05-22 22:07:09 -05:00
'dockerls',
'eslint',
'html',
'jdtls',
'kotlin_language_server',
2022-05-19 08:58:39 -05:00
'terraformls',
'tflint',
2022-05-22 22:07:09 -05:00
'tsserver',
'vimls',
'vuels',
2022-05-26 16:25:34 -05:00
'tsserver',
2022-06-01 23:16:46 -05:00
'jsonls',
2022-06-12 23:32:45 -05:00
'pyright',
2022-05-06 20:44:22 -05:00
}) do
2022-05-06 16:52:44 -05:00
lspconfig[server].setup(opts)
end