From 23cf10e11632e2acc23c33a665bc40e0b2a60bc8 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Wed, 24 Jul 2024 01:37:26 +0200 Subject: Update snippets --- fnl/plugins/cmp.fnl | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'fnl') diff --git a/fnl/plugins/cmp.fnl b/fnl/plugins/cmp.fnl index 3b8c1da..2a8d280 100644 --- a/fnl/plugins/cmp.fnl +++ b/fnl/plugins/cmp.fnl @@ -61,24 +61,31 @@ :sources [{:name :path} {:name :cmdline :option {:ignore_cmds [:Man "!"]}}]}) - (let [luasnip (require :luasnip)] - (luasnip.config.set_config {:history false - :updateevents "TextChanged,TextChangedI"}) - (luasnip.add_snippets :org [(luasnip.parser.parse_snippet :be "#+begin_src $1\n$2\n#+end_src")]) + (let [ls (require :luasnip) + fmt (require :luasnip.extras.fmt)] + (ls.config.set_config {:history false + :updateevents "TextChanged,TextChangedI"}) + (let [s ls.s + i ls.insert_node + fmt fmt.fmt] + (ls.add_snippets :org + [(s :be + (fmt "#+begin_src {}\n{}\n#+end_src" + [(i 1) (i 2)]))])) (vim.keymap.set [:i :s] : (lambda [] - (when (luasnip.expand_or_jumpable) - (luasnip.expand_or_jump))) + (when (ls.expand_or_jumpable) + (ls.expand_or_jump))) {:silent true}) (vim.keymap.set [:i :s] : (lambda [] - (when (luasnip.jumpable -1) - (luasnip.jump -1)) + (when (ls.jumpable -1) + (ls.jump -1)) {:silent true})) (vim.keymap.set [:i] : (lambda [] - (when (luasnip.choice_active) - (luasnip.change_choice 1))) + (when (ls.choice_active) + (ls.change_choice 1))) {:silent true})))) {1 :hrsh7th/nvim-cmp : dependencies :event :InsertEnter : config} -- cgit v1.2.3-70-g09d2