-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for regex-based triggers (LuaSnip) #1373
Comments
This won't be supported in the core but you could detect these yourself and call |
I don't think that's it.
|
Aha, sorry I read this too quickly and missed that they were being filtered out. Related #1375 |
Alright, after updating to that super fresh PR and playing around, the problem is simple (if my understanding is correct).
Any opinions, @soifou (thanks by the way)? |
I think it totally makes sense! Could you share your "nice full date" regex snippet if you don't mind? I'd like to toy around with a reasonable set of snippets to make sure it works as expected before making a new PR. |
A bit tricky since written in Fennel and calling into my private lib, but to give you an idea: (LS/s {:trig "(%d%d%d%d)(%d%d)(%d%d)"
:name "date_link"
:doctrig "20240312"
:desc "Inserts Markdown link for the given date"
:regTrig true}
(LS/f (fn [_args {: captures}]
($/zet/link.date (numeric-capture captures
1)
(numeric-capture captures
2)
(numeric-capture captures
3)))
{})) It captures the year + month + day and calls a function for generating a nice Markdown link to a local "daily note". So to recap the above thinking, the idea is that it would be more intuitive to search for that snippet using its A another problem with the current pattern-based approach is that the completion menu disappears as digits are typed. This makes sense if you know that those patterns are not incremental. But from a UI perspective, it does not feel intuitive that the menu disappears as you type something that is actually valid. Sadly, that cannot be solved without a signifcant headache. Therefore, after sleeping on it, I keep returning to this idea of using |
This addresses an issue where snippets composed only by lua regex patterns make them barely searchable in the completion menu. Luasnip provides a `name` property that, when available, display the snippet's `name` instead of the raw regex `trigger` pattern, making regex triggers discoverable and user-friendly. Related to Saghen#1373 Co-authored-by: helins <[email protected]>
) This addresses an issue where snippets composed only by lua regex patterns make them barely searchable in the completion menu. Luasnip provides a `name` property that, when available, display the snippet's `name` instead of the raw regex `trigger` pattern, making regex triggers discoverable and user-friendly. Related to #1373 Co-authored-by: helins <[email protected]>
Thank you for the detail answer! Did some tests today and think the |
Thanks for the prompt implementation! Maybe one more thing, more controversial. When accepting a selection, instead of inserting In the example above, |
Improves readability of expanded luasnip regex trigger by using `docTrig` as a placeholder (when available) instead of the less intuitive regex pattern. For example, expanding a snippet with the trigger `(%d%d%d%d)(%d%d)(%d%d)` would insert `20250303` rather than the regex itself. Fix Saghen#1373
@helins could you try my fork using the branch sources = {
providers = {
snippets = {
--- @type blink.cmp.LuasnipSourceOptions
opts = {
prefer_doc_trig = true
},
},
},
}, |
Feature Description
I have some LuaSnip snippets triggered by regexes.
E.g. Insert a nice full date when I type something like
20250302
.Those triggers:
auto_show
trig
) rather than theirname
trig
The text was updated successfully, but these errors were encountered: