-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Bug] Cannot extend ls.multi_snippet
#921
Comments
Ah, it's possible we don't have that set up yet. |
Thanks for your prompt reply, will look into it later. |
For future reference: To register the multi-snippet function, just call local ls = require('luasnip')
local ms = ls.multi_snippet
ls.extend_decorator.register(ms, { arg_indx = 1 }, { arg_indx = 3 }) |
(also added this in 1a42854, with slightly different behaviour: if |
@L3MON4D3 Currently the To clarify, consider the following cases: I create some luasnip conds and define a new multi-snippet that only expand if ts is not active or ts and active and the cursor is not in a comment or string: local msc = ls.extend_decorator.apply(ms, {
common = {
condition = -conds.ts_active
+ -conds.in_tsnode('comment') * -conds.in_tsnode('string'),
show_condition = -conds.ts_active
+ -conds.in_tsnode('comment') * -conds.in_tsnode('string'),
},
}) Then I want to create a multi-snippet with regex trigger and only expand when the cursor is not in a comment or string: msc(
{
common = { regTrig = true },
{ trig = '(%S?)(%s*)%.%.%s*ck' },
{ trig = '(%S?)(%s*)%.%.%s*check' },
},
fmta('<spc>.. ", <v>: " .. vim.inspect(<v>)', {
spc = f(function(_, snip, _)
return snip.captures[1] == '' and snip.captures[2]
or snip.captures[1] .. ' '
end, {}, {}),
v = i(1),
}, { repeat_duplicates = true })
) the original condition field is dropped because I provide the I would suggest using -- extend ("keep") valid keyword-arguments.
passed_arg.common = vim.tbl_deep_extend(
"keep",
passed_arg.common or {},
extend_arg.common or {}
) EDIT: typo |
I tried to extend
ls.multi_snippet
with the following code:but get this error:
Seems that multi-snippets cannot be extended like normal snippets? Is this intended or a bug? Thanks in advance!
The text was updated successfully, but these errors were encountered: