saadparwaiz1/cmp_luasnip

Jump to placeholders in snippet

TroySigX opened this issue · 2 comments

My snippet has more than 1 placeholders for me to type in, example in snipmate-style. How do I create mapping so that I can jump between those placeholders?

I just figured it out:
[""] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),

Sorry, I meant this:
local keymap = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
keymap("i", "", "lua require'luasnip'.jump(1)", opts)
keymap("s", "", "lua require'luasnip'.jump(1)", opts)
keymap("i", "", "lua require'luasnip'.jump(-1)", opts)
keymap("s", "", "lua require'luasnip'.jump(-1)", opts)