diff options
Diffstat (limited to 'fnl/plugins/lsp/keymaps.fnl')
-rw-r--r-- | fnl/plugins/lsp/keymaps.fnl | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/fnl/plugins/lsp/keymaps.fnl b/fnl/plugins/lsp/keymaps.fnl index a7fac89..9b95140 100644 --- a/fnl/plugins/lsp/keymaps.fnl +++ b/fnl/plugins/lsp/keymaps.fnl @@ -1,23 +1,21 @@ ;; Key mappings for lsp. -(fn on-attach [bufnr] (let [opts {:noremap true :silent true}] - (vim.api.nvim_buf_set_keymap bufnr :n :gD - "<cmd>lua vim.lsp.buf.declaration()<CR>" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gd - "<cmd>lua vim.lsp.buf.definition()<CR>" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gI - "<cmd>lua vim.lsp.buf.implementation()<CR>" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gr - "<cmd>lua vim.lsp.buf.references()<CR>" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gl - "<cmd>lua vim.diagnostic.open_float()<CR>" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gs - "<cmd>lua vim.lsp.buf.signature_help()<CR>" - opts))) +(local opts {:noremap true :silent true}) + +(local mappings + [[:n :gD "<cmd>lua vim.lsp.buf.declaration()<CR>"] + [:n :gd "<cmd>lua vim.lsp.buf.definition()<CR>"] + [:n :gI "<cmd>lua vim.lsp.buf.implementation()<CR>"] + [:n :gr "<cmd>lua vim.lsp.buf.references()<CR>"] + [:n :gl "<cmd>lua vim.diagnostic.open_float()<CR>"] + [:n :gs "<cmd>lua vim.lsp.buf.signature_help()<CR>"]]) + +(fn buf-set-keymap [bufnr mode key cmd opts] + (vim.api.nvim_buf_set_keymap bufnr mode key cmd opts)) + +(fn on-attach [bufnr] + (each [_ mapping (ipairs mappings)] + (match mapping + [mode key cmd] (buf-set-keymap bufnr mode key cmd opts)))) {: on-attach} |