diff options
Diffstat (limited to 'nvim/lua/lsp_conf.lua')
-rw-r--r-- | nvim/lua/lsp_conf.lua | 35 |
1 files changed, 35 insertions, 0 deletions
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', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) + buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) + buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) + buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) + buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) + buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts) + buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) + buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', 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 |