I've been attempting to learn luasnips for the past few days, and the example given under Optional Noderef in the documentation, seen below, was not working for me.
ls.snip_expand(s("trig", {
d(1, function(args)
if not args[1] then
-- the arg does not exist -> provide a default.
return sn(nil, {i(1, "asdf", {key = "ins"})})
else
-- This branch is only take after the dynamicNode was updated once.
-- Now we can perform the actual "task" of this dynamicNode:
-- replacing all occurences of "a" with "e".
return sn(nil, {i(1, args[1][1]:gsub("a", "e"), {key = "ins"})})
end
end, {opt(k("ins"))})
}))
The error being thrown said I was attempting to call a table.
The culprit was the fact that I had placed the line local opt = require("luasnip.nodes.optional_arg") into my file earlier, which is what the documentation claims opt is set to in all code snippets. I believe it is actually set to local opt = require("luasnip.nodes.optional_arg").new_opt since that fixed the issue (also, deleting the line altogether worked, so clearly there is a disconnect between the documentation and what is actually occurring).
Not sure if this is something to i should place under the issues tab, so apologies if I'm mistaken.
I've been attempting to learn luasnips for the past few days, and the example given under Optional Noderef in the documentation, seen below, was not working for me.
The error being thrown said I was attempting to call a table.
The culprit was the fact that I had placed the line
local opt = require("luasnip.nodes.optional_arg")into my file earlier, which is what the documentation claimsoptis set to in all code snippets. I believe it is actually set tolocal opt = require("luasnip.nodes.optional_arg").new_optsince that fixed the issue (also, deleting the line altogether worked, so clearly there is a disconnect between the documentation and what is actually occurring).Not sure if this is something to i should place under the issues tab, so apologies if I'm mistaken.