saadparwaiz1 / cmp_luasnip

luasnip completion source for nvim-cmp
Apache License 2.0
712 stars 32 forks source link

return empty documentation if snip = nil #38

Closed wuilliam321 closed 2 years ago

wuilliam321 commented 2 years ago

Maybe there is another reason why snip is nil, but it fails when trying to navigate cmp dropdown.

L3MON4D3 commented 2 years ago

Mhm, that's a fix for the errors, but I'm not sure if failing silently if we don't even know where the error originates is the best idea. There could be more problems if snip is nil, it cannot be expanded for example.

wuilliam321 commented 2 years ago

I found another way to make it work, but, i'll leave here the way I reproduce the error;

local ls = require'luasnip'

ls.snippets = {
  all = {ls.parser.parse_snippet('expand', '-- this is an expanded snippet')},
}

then when you write expand and choose the snippet from cmp dropdown, the error happens

But,

this way works great:

local ls = require'luasnip'

local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node

ls.add_snippets('all', {
  s('ternary', {
    i(1, 'cond'),
    t(' ? '),
    i(2, 'then'),
    t(' : '),
    i(3, 'else'),
  }),
})