local lsp = require 'lspconfig' -- local coq = require'coq' -- TODO: replace with nvim lsp bindings for jumping to next linting issue? --vim.api.nvim_set_keymap('n', '[d', ')', opts) local opts = { noremap = true, silent = true, } local lsp_format = require 'lsp-format' local on_attach = function(client, bufnr) lsp_format.on_attach(client) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'e', 'lua vim.diagnostic.open_float()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g]', 'lua vim.diagnostic.goto_next()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g[', 'lua vim.diagnostic.goto_prev()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'i', '', 'lua vim.lsp.buf.signature_help()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting_seq_sync()', opts) end local capabilities = require 'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities()) local common_config = { capabilities = capabilities, on_attach = on_attach, flags = { debounce_text_changes = 150 }, } --[[ set els_path ~/.local/share/nvim/lsp_servers/elixir curl -fLO https://github.com/elixir-lsp/elixir-ls/releases/latest/download/elixir-ls.zip mkdir -p $els_path unzip elixir-ls.zip -d $els_path/elixir-ls/ chmod +x $els_path/elixir-ls/language_server.sh ]] local lsp_configs = { gopls = {}, elixirls = { cmd = { vim.fn.expand '~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' }, settings = { elixirLS = { dialyzerEnabled = true, fetchDeps = false, } } }, sumneko_lua = { settings = { Lua = { diagnostics = { globals = { 'vim' } } } } }, vimls = {}, rust_analyzer = {}, -- tsserver = {}, pylsp = {}, denols = { root_dir = lsp.util.root_pattern("deno.json"), }, } for server, config in pairs(lsp_configs) do for k, v in pairs(common_config) do config[k] = v end lsp[server].setup(config) end require'nvim-lsp-installer'.setup{ automatic_installation = true, }