cmp_luasnip icon indicating copy to clipboard operation
cmp_luasnip copied to clipboard

Keep getting sporadic errors (may be related to packer.nvim?)

Open mawkler opened this issue 3 years ago • 7 comments

Every now and then I get the error below. I've tried to find a way to reproduce it but it's very difficult. I think it only occurs after I run source <afile> | PackerCompile after saving my init.lua, and it appears to trigger randomly every now and then when I type in insert mode and a snippet appears as the hovered selection in the popup menu.

Without a way to reproduce it's not much help but I still wanted to post this issue to hear if there's an easy fix or if anyone else is having the same issue.

Error executing vim.schedule lua callback: ...e/pack/packer/start/cmp_luasnip/lua/cmp_luasnip/init.lua:106: attempt to index a nil value
stack traceback:
	...e/pack/packer/start/cmp_luasnip/lua/cmp_luasnip/init.lua:106: in function 'resolve'
	.../nvim/site/pack/packer/start/nvim-cmp/lua/cmp/source.lua:348: in function 'resolve'
	...e/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/entry.lua:454: in function 'resolve'
	...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/view.lua:225: in function 'fn'
	.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:41: in function <.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:39>

mawkler avatar Mar 25 '22 21:03 mawkler

I don't know much about packer's internals, does it change anything about the loaded plugins when PackerCompile is called? Your error "shouldn't" occur during normal usage I think.

L3MON4D3 avatar Mar 27 '22 09:03 L3MON4D3

Try find for get_documentation function and add:

local function get_documentation(snip, data)
	if snip == nil then
		return ""
	end
	local header = (snip.name or "") .. " _ `[" .. data.filetype .. "]`\n"
        ...

wuilliam321 avatar Mar 27 '22 19:03 wuilliam321

@melkster Could you make sure you're adding snippets via ls.add_snippets(ft, snippets)? I didn't consider that not everybody is using that already (it is deprecated, but not yet unsupported).

L3MON4D3 avatar Mar 28 '22 07:03 L3MON4D3

What is deprecated? get_documentation?

wuilliam321 avatar Mar 28 '22 19:03 wuilliam321

@wuilliam321 adding snippets by directly accessing the snippet table

saadparwaiz1 avatar Mar 28 '22 19:03 saadparwaiz1

Could you make sure you're adding snippets via ls.add_snippets(ft, snippets)?

This might actually be it! I wasn't using ls.add_snippets() and after changing to it I haven't experienced the issue!

mawkler avatar Mar 29 '22 14:03 mawkler

Great! was the same for me!

wuilliam321 avatar Mar 29 '22 17:03 wuilliam321