How do I have multiple trigger for lua
snippet?
#775
budimanjojo
started this conversation in
General
Replies: 2 comments 2 replies
-
Don't think there's a built-in solution, but I'm pretty sure you can try the following:
For example, here is some skeleton code you can play around with: local dummy_test = function(context, snippet, opts)
opts = opts or {}
if not context.trig then
error("context doesn't include a `trig` key which is mandatory", 2)
end
return s(context, snippet, opts)
end
local dummy_test_specs = {
"dummy1", "dummy2", "dummy3" -- replace with other keywords you want to use
}
local dummy_snippet_body = {
t("this is a dummy test snippet"),
i(1), c(2, {t("more text"), i(1)})
}
local dummy_test_snippets = {}
for _, v in ipairs(dummy_test_specs) do
table.insert(dummy_test_snippets, dummy_test({ trig = v }, dummy_snippet_body, { condition = in_text }))
end
vim.list_extend(M, dummy_test_snippets) -- this assumes M is the table of snippets; change if needed |
Beta Was this translation helpful? Give feedback.
1 reply
-
Oh wow, great timing, I just worked on that xD |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! In
vscode
snippets, we can have multiple "prefix" to trigger the snippet. Is there a way to achieve this withlua
snippet?context.trig
is type ofstring
so I don't think it's supported, but maybe there's a better workaround that I don't know of? Thanks!Beta Was this translation helpful? Give feedback.
All reactions