luasnip-snippets icon indicating copy to clipboard operation
luasnip-snippets copied to clipboard

Is the Lua snippet `fun(ction)?` supposed to look like that?

Open mawkler opened this issue 1 year ago • 7 comments

The Lua snippet fun(ction)? is not expandable for me. Is it supposed to look like that?

mawkler avatar Aug 31 '24 22:08 mawkler

@mawkler this triggers for:

  • fun
  • function

Here is source

This is regex trigger and it has no list of alternatives to export to cmp. There are other triggers like lorem(number) which generates lorem ipsum with requested number of words. It's not practically possible to generate list of working alternatives to completion.

mireq avatar Sep 07 '24 12:09 mireq

@mireq So what you're saying is that the fun(ction) snippet does not work with LuaSnip? If that's the case, is it possible for luasnip-snippets to filter out those regex snippets so that they don't show up?

mawkler avatar Sep 09 '24 07:09 mawkler

@mawkler it works, you can write fun or function. This is more cmp_luasnip issue. I think it should be displayed in list to show possible regex capture.

mireq avatar Sep 09 '24 07:09 mireq

@mireq Are you sure that it's a cmp_luasnip issue? I can't activate it with your minimal_lazy.lua config. If I type func, funct, functi, functio or function and press <Tab> with your config it doesn't work.

I can do fun, but that seems to be a different fun snippet.

mawkler avatar Sep 09 '24 07:09 mawkler

@mawkler it should trigger only using fun and function. Rregex tells, that it should start with fun and then optionally can have ction suffix (exactly this, not shorter). So only fun and function expands this snippet.

Correct shippet is here. It has higher priority.

mireq avatar Sep 09 '24 10:09 mireq

@mireq But, it doesn't trigger for function. When looking at the source snippet from ultisnips I noticed that there's only a fun(ction) and no fun snippet, like lusnip-snippet has. Luasnip-snippets transpiles the ultisnips snippet to Lua, right? Does that mean that there should be fun and function snippet in LuaSnip, rather than a fun and a (broken) fun(ction) snippet?

mawkler avatar Sep 09 '24 12:09 mawkler

@mawkler no, it's regular expression for both cases, so fun(ction) matches both, fun and function, but it don't display completion.

mireq avatar Sep 22 '24 16:09 mireq