diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2023-01-13 01:35:12 +0100 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2023-01-13 01:35:12 +0100 |
commit | 8d8cf86821d7cc1b093d149389baf5272e8033ca (patch) | |
tree | 793346b35c1ce6c60e0f7ee96c7e9696c3a2a36d /fnl/plugins/lsp | |
parent | ac8af14d5137de52ce12f432d61b1c3f9f8c185b (diff) |
Refactor settings and plugins
Diffstat (limited to 'fnl/plugins/lsp')
-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} |