I am trying to create a snippet that changes based on the optional lua pattern input, but I am getting an error about a local tmp for the dynamic node. The desired outcome for typing $cup$ is $\cup$ while for $bcup$, $\bigcup_{<>}^{<>} and I get this error when typing $cup$ or $bcup$. My indexing for the dynamic node seems fine. Any clarification on how to fix this, or why I get this for the dynamic node and not the function node would be appreciated.
Snippet:
return{
s({trig = '([b]?)cup', wordTrig = false, regTrig = true, snippetType = 'autosnippet'},
fmta("\\\\<>cup<>",
{
f(function(\_, snip)
if snip.captures\[1] == 'b' then
return 'big'
end
end),
d(1, function(\_, snip)
if snip.captures\[1] == 'b' then
return sn(nil, { t("_{"), i(1), t("}^{"), i(2), t("}") })
end
end),
}
)
),
}
Error Message:
Error detected while processing TextChangedI Autocommands for "*":
Error executing lua callback: ...hare/nvim/lazy/LuaSnip/lua/luasnip/nodes/dynamicNode.lua:154: attempt to index local 'tmp' (a nil value)