From 930607a63aa9e0643bb2a2bd35991e2af890cfc4 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 4 Jan 2024 16:02:10 -0700 Subject: [PATCH] Maintain `` and `` functionality in insert/select mode. --- .../jrpotter/neovim/config/utils/luasnip.lua | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/users/jrpotter/neovim/config/utils/luasnip.lua b/users/jrpotter/neovim/config/utils/luasnip.lua index ef3ad69..0b58327 100644 --- a/users/jrpotter/neovim/config/utils/luasnip.lua +++ b/users/jrpotter/neovim/config/utils/luasnip.lua @@ -33,26 +33,22 @@ function M.setup() }, } - vim.keymap.set( - { 'i', 's' }, - '', - function() - if luasnip.choice_active() then - luasnip.change_choice(1) - end - end, - { silent = true } - ) - vim.keymap.set( - { 'i', 's' }, - '', - function() - if luasnip.choice_active() then - luasnip.change_choice(-1) - end - end, - { silent = true } - ) + vim.keymap.set({ 'i', 's' }, '', function() + if luasnip.choice_active() then + return 'luasnip-next-choice' + else + return '' + end + end, { silent = true, expr = true, remap = true }) + + vim.keymap.set({ 'i', 's' }, '', function() + if luasnip.choice_active() then + return 'luasnip-prev-choice' + else + return '' + end + end, { silent = true, expr = true, remap = true }) + -- Allow aborting the active snippet at any point in time. vim.keymap.set( { 'n', 'i', 's' },