From 51d1f5835aaa4491025769fd635dd262aa3ce55d Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Fri, 17 May 2024 00:14:37 +0200 Subject: Improve cmp --- fnl/plugins/cmp.fnl | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'fnl/plugins') diff --git a/fnl/plugins/cmp.fnl b/fnl/plugins/cmp.fnl index 24beee0..1745191 100644 --- a/fnl/plugins/cmp.fnl +++ b/fnl/plugins/cmp.fnl @@ -12,15 +12,15 @@ (fn config [] (let [cmp (require :cmp) lspkind (require :lspkind) - luasnip (require :luasnip) luasnip-vscode (require :luasnip.loaders.from_vscode)] (luasnip-vscode.lazy_load) (lspkind.init) - (cmp.setup {:snippet {:expand (fn [args] - (luasnip.lsp_expand args.body))} + (cmp.setup {:snippet {:expand (lambda [args] + (let [luasnip (require :luasnip)] + (luasnip.lsp_expand args.body)))} :completion {:completopt "menu,menuone,noinsert"} - :mapping (cmp.mapping.preset.insert {: (cmp.mapping.select_prev_item {:behavior cmp.SelectBehavior.Insert}) - : (cmp.mapping.select_next_item {:behavior cmp.SelectBehavior.Insert}) + :mapping (cmp.mapping.preset.insert {: (cmp.mapping.select_prev_item {:behavior cmp.SelectBehavior.Insert}) + : (cmp.mapping.select_next_item {:behavior cmp.SelectBehavior.Insert}) : (cmp.mapping (cmp.mapping.confirm {:behavior cmp.SelectBehavior.Insert :select true} [:i @@ -54,6 +54,19 @@ {:mapping (cmp.mapping.preset.cmdline) :sources [{:name :path} {:name :cmdline - :option {:ignore_cmds [:Man "!"]}}]}))) + :option {:ignore_cmds [:Man "!"]}}]}) + (let [luasnip (require :luasnip)] + (luasnip.config.set_config {:history false + :updateevents "TextChanged,TextChangedI"}) + (vim.keymap.set [:i :s] : + (lambda [] + (when (luasnip.expand_or_jumpable) + (luasnip.expand_or_jump))) + {:silent true}) + (vim.keymap.set [:i :s] : + (lambda [] + (when (luasnip.jumpable -1) + (luasnip.jump -1)) + {:silent true}))))) {1 :hrsh7th/nvim-cmp : dependencies :event :InsertEnter : config} -- cgit v1.2.3-70-g09d2