From e8b2ba6516cf5b5bb23282acb4ebdd30b12e4fee Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 3 Nov 2021 21:00:17 +0100 Subject: use telescope and new statusline --- nvim/lua/lsp_conf.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 nvim/lua/lsp_conf.lua (limited to 'nvim/lua/lsp_conf.lua') diff --git a/nvim/lua/lsp_conf.lua b/nvim/lua/lsp_conf.lua new file mode 100644 index 0000000..a63b761 --- /dev/null +++ b/nvim/lua/lsp_conf.lua @@ -0,0 +1,35 @@ +local nvim_lsp = require('lspconfig') +local coq = require('coq') + +local on_attach = function(client, bufnr) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + + -- Mappings. + local opts = { noremap=true, silent=true } + + -- See `:help vim.lsp.*` for documentation on any of the below functions + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) +end + +-- Setup lspconfig. + +--- Use a loop to conveniently call 'setup' on multiple servers and +-- map buffer local keybindings when the language server attaches +local servers = { 'jedi_language_server', 'rust_analyzer', 'tsserver', 'clangd' } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + capabilities = coq.lsp_ensure_capabilities(), + on_attach = on_attach, + flags = { + debounce_text_changes = 150, + } + } +end -- cgit v1.2.3-71-g8e6c