hrsh7th/cmp-vsnip

Duplicate expansion

hinell opened this issue · 2 comments

Peek.2023-01-30.00-47.mp4

Having a weird duplicate expansion. Tab keys aren't working for jumps.

--Approximate config
-- plugins-snippets.lua

local cmp = require("cmp")
cmp.setup({

["<CR>"] = cmp.mapping.confirm({ select = true }),
["<C-S-j>"] = cmp.mapping(function(fallback)
	if vim.fn["vsnip#jumpable"](1) == 1 then
		 feedkey("<Plug>(vsnip-jump-next")
	else
		fallback()
	end
end, {  "s" }),
["<Tab>"] = cmp.mapping(function(fallback)
 --  elseif vim.fn["vsnip#available"](1) == 1 then
	if vim.fn["vsnip#jumpable"](1) == 1 then
		 feedkey("<Plug>(vsnip-jump-next", "")
	elseif cmp.visible() then
		cmp.select_next_item()
	elseif has_words_before() then
		cmp.complete()
	else
	  --The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
		fallback()
	 end
end, { "i", "s" }),

["<S-Tab>"] = cmp.mapping(function()
  if vim.fn["vsnip#jumpable"](-1) == 1 then
	  feedkey("<Plug>(vsnip-jump-prev)", "")
  elseif cmp.visible() then
	  cmp.select_prev_item()
  end
end, { "i", "s" }),


...
end -- setup end
Snippet:
	"workspace doc open": {
		"prefix": "doc.open.content",
		"body": [
			"workspace.openTextDocument({",
			"    content : ${1:\"File content\"},",
			"    language: \"${2|javascript,typescript,texmate.snippet|}\"",
			"});"
		],
		"description": "Open vs code workspace document"
	}

Version

Closing this issue, cause the original problem may come from two consequent calls like:

...
cmp.confirm()
luasnip.expand()

Watch out your version!

See also related discussion hrsh7th/nvim-cmp#1447