-
Hello, local function table_contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
local no_space_in_front = { ' ', ',', '.', '?', '-' }
local optional_space_node = function(insert_node_id)
return function_node(function (args)
if args[1][1] == '' then
return 'nospace'
end
if table_contains(no_space_in_front, string.sub(args[1][1], 1, 1)) then
return "nospace"
else
return "space"
end
end,
insert_node_id)
end
ls.add_snippets("tex", {
snippet({
trig="mk",
name="inline_math",
dscr="An inline math formula.",
wordTrig=true,
regTrig=false,
},
{
text_node("$"), insert_node(1), text_node("$"), optional_space_node(0), insert_node(0)
}),
},
{type = "autosnippets",}
) If I change the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This is pretty much correct, the problem is just that the |
Beta Was this translation helpful? Give feedback.
This is pretty much correct, the problem is just that the
i(0)
is not really an insertNode, so luasnip cant find the node the fNode depends on, and therefore just does not run it :/ (there already are some issues about this which contain reasoning, I won't repeat that here).I recall proposing a solution to a problem very similar to yours, could you try searching through old issues/discussions?
If you don't find anything I can look into this again :)