From 984feefe0c4de184eed8151260d475c99ac1eeab Mon Sep 17 00:00:00 2001 From: sefidel Date: Sat, 26 Feb 2022 22:15:29 +0900 Subject: fix(cmp): fix cmp completion --- fnl/nvrc/packs/cmp.fnl | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'fnl/nvrc/packs') 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 @@ : (cmp.mapping.scroll_docs 4) : (cmp.mapping.complete) : (cmp.mapping.close) - : (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace - :select true}) - :Tab (fn [fallback] - (if (cmp.visible) (cmp.select_next_item)"") - (fallback)) - : (fn [fallback] - (if (cmp.visible) (cmp.select_next_item)"") - (fallback))} + : (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})}) + : (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}]}) -- cgit 1.4.1