diff options
Diffstat (limited to 'fnl/nvrc/packs/cmp.fnl')
-rw-r--r-- | fnl/nvrc/packs/cmp.fnl | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/fnl/nvrc/packs/cmp.fnl b/fnl/nvrc/packs/cmp.fnl index 0f36592..0ff8dc2 100644 --- a/fnl/nvrc/packs/cmp.fnl +++ b/fnl/nvrc/packs/cmp.fnl @@ -1,5 +1,6 @@ (import-macros {: set!} :nvrc.macro.set) (local cmp (require :cmp)) +(local luasnip (require :luasnip)) (set! completeopt "menuone,noselect") @@ -29,7 +30,8 @@ :Operator "(op)" :TypeParameter "(tp)"}) -(cmp.setup { +(cmp.setup {:snippet {:expand (fn [args] + ((. (require :luasnip) :lsp_expand) args.body))} :formatting {:format (fn [entry vim-item] (set vim-item.kind (string.format "%s %s" @@ -45,13 +47,17 @@ :<C-f> (cmp.mapping.scroll_docs 4) :<C-Space> (cmp.mapping.complete) :<C-e> (cmp.mapping.close) - :<CR> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace - :select true}) - :Tab (fn [fallback] - (if (cmp.visible) (cmp.select_next_item)"") - (fallback)) - :<S-Tab> (fn [fallback] - (if (cmp.visible) (cmp.select_next_item)"") - (fallback))} + :<CR> (cmp.mapping (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace + :select false}) [:i :c]) + :Tab (cmp.mapping {:i (fn [fallback] + (if (cmp.visible) (cmp.select_next_item) + (luasnip.expand_or_jumpable) (luasnip.expand_or_jump) + (fallback))) + :c (cmp.mapping.select_prev_item {:select true})}) + :<S-Tab> (cmp.mapping {:i (fn [fallback] + (if (cmp.visible) (cmp.select_next_item) + (luasnip.jumpable -1) (luasnip.jump -1) + (fallback))) + :c (cmp.mapping.select_prev_item {:select true})})} :sources [{:name :nvim_lsp} {:name :nvim_lsp_signature_help}]}) |