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/pack.fnl | 1 + fnl/nvrc/packs/cmp.fnl | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'fnl/nvrc') diff --git a/fnl/nvrc/pack.fnl b/fnl/nvrc/pack.fnl index 8cd92b0..1e544da 100644 --- a/fnl/nvrc/pack.fnl +++ b/fnl/nvrc/pack.fnl @@ -24,6 +24,7 @@ (pack! :lewis6991/spaceless.nvim {:init :spaceless :defer :spaceless.nvim}) (pack! :stefandtw/quickfix-reflector.vim {:ft :qf}) +(pack! :L3MON4D3/LuaSnip {:module :luasnip}) (pack! :hrsh7th/nvim-cmp {:req :cmp :event :InsertEnter}) (pack! :numToStr/Comment.nvim {:module :Comment :init :Comment}) (pack! :ibhagwan/fzf-lua {:req :fzf :module :fzf-lua}) 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