L3MON4D3 / LuaSnip

Snippet Engine for Neovim written in Lua.
Apache License 2.0
3.51k stars 246 forks source link

Match multiple snippets #1021

Open mireq opened 1 year ago

mireq commented 1 year ago

I am trying to convert all UltiSnips snippets to luasnip with exact same behavior (including duplicate triggers, embedded scripts ...).

To reproduce snippet menu (displayed with multiple matches) i need find all matching snippets, but there is only M.match_snippet exposed. I can't use choice node, because match function can be different for each snippet.

It would be nice to have function, which matches all snippets, or at least prio_iter function to implement my own.

L3MON4D3 commented 1 year ago

Oh, we don't have that built-in, I think the most common solution for this is cmp_luasnip

mireq commented 1 year ago

This is just autocompletion, right? I want execute trigger and show all matched snippets. For example in actionscript (i don't write actionscript, it's juset first language in alphabetic order) for has 3 different snippets. UltiSnips in this case shows menu with choices. Theoretically i can replicate this behavior with choice node, but it will not work for snippets triggered using different match expression.

for

L3MON4D3 commented 1 year ago

Ahh okay I understand We don't have something like this yet, but it seems like a cool addition. We could just extend the api for match_snippet to optionally return all matches (want to have the option to still abort on first match), and just pass all of them through vim.ui.select().