From d517c03abbf4c7fa971bbe11035b7c3458590d35 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Fri, 1 Jul 2022 17:03:36 +0200 Subject: vim: some work on snippets --- .vim/lua/plugins.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to '.vim/lua/plugins.lua') diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index eb62b1e..67a0e88 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -504,8 +504,8 @@ require('packer').startup({function() i = function(fallback) if cmp.visible() then cmp.confirm({ select = true }) - elseif luasnip.expandable() then - luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() else fallback() end @@ -513,6 +513,8 @@ require('packer').startup({function() s = function(fallback) if cmp.visible() then cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() else fallback() end @@ -541,6 +543,21 @@ require('packer').startup({function() end end, }), + -- map c-j/k for luasnip choice nodes + [''] = cmp.mapping(function(fallback) + if luasnip.choice_active() then + luasnip.change_choice(1) + else + fallback() + end + end, { 'i', 's'}), + [''] = cmp.mapping(function(fallback) + if luasnip.choice_active() then + luasnip.change_choice(-1) + else + fallback() + end + end, { 'i', 's'}), }, snippet = { expand = function(args) -- cgit 1.4.1