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 function on_attach(client, bufnr) async.run(function() vim.notify.async('Attached server ' .. client.name, 'info', { title = 'Lsp Attach', }).events.close() end) end local lsp_capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) local opts = { capabilities = lsp_capabilities, on_attach = on_attach, } -- 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 = opts, dap = { adapter = require('rust-tools.dap').get_codelldb_adapter(codelldb_path, liblldb_path), }, tools = { hover_actions = { auto_focus = true }, crate_graph = { backend = 'svg', output = 'Rust-Crate-Graph-' .. os.time() .. '.svg', }, }, } 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({ settings = { ansible = { ansible = { useFullyQualifiedCollectionNames = true, path = 'ansible', }, ansibleLint = { enabled = true, path = 'ansible-lint', }, python = { interpreterPath = 'python3', }, }, }, }) -- NOTE: BASH LSP lspconfig.bashls.setup({ filetypes = { 'zsh', 'bash', 'sh', }, opts, }) -- NOTE: LUA LSP local luadev = require('lua-dev').setup({ lspconfig = opts, }) lspconfig.sumneko_lua.setup(luadev) -- NOTE: SQL LSP lspconfig.sqls.setup({ on_attach = function(client, bufnr) require('sqls').on_attach(client, bufnr) end, }) -- NOTE: PYTHON LSP lspconfig.pylsp.setup({ on_attach = on_attach, filetypes = { 'python' }, settings = { formatCommand = { 'black' }, pylsp = { plugins = { jedi_completion = { include_params = true, fuzzy = true, eager = true, }, jedi_signature_help = { enabled = true }, pyflakes = { enabled = true }, -- pylint = {args = {'--ignore=E501,E231', '-'}, enabled=true, debounce=200}, pylsp_mypy = { enabled = true }, pycodestyle = { enabled = true, ignore = { 'E501', 'E231' }, maxLineLength = 120, }, yapf = { enabled = true }, }, }, }, }) lspconfig.yamlls.setup({ settings = { yaml = { schemas = { ['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*', ['https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json'] = '/azure-pipeline.y*l', ['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', }, }, }, }) -- NOTE: GENERIC LSP SERVERS for _, server in ipairs({ 'clangd', 'cmake', 'dockerls', 'eslint', 'html', 'jdtls', 'kotlin_language_server', 'omnisharp', 'terraformls', 'tflint', 'tsserver', 'vimls', 'vuels', 'tsserver', }) do lspconfig[server].setup(opts) end