LuaSnip icon indicating copy to clipboard operation
LuaSnip copied to clipboard

Snippet expansion is not considered as function node reevaluation-trigger

Open micangl opened this issue 7 months ago • 2 comments

I have the following snippets:

local f1 = function(args, parent)
  if string.match(args[1][1], [[\frac]]) then
    return [[\left]]
  else
    return ""
  end
end
local f2 = function(args, parent)
  if string.match(args[1][1], [[\frac]]) then
    return [[\right]]
  else
    return ""
  end
end
s({trig = "()", priority = 1000, condition = in_mathzone, wordTrig = false, snippetType = "autosnippet"}, fmta([[<>(<><>)]], {f(f1, {1}), i(1), f(f2, {1})}))

s({trig = "//", dscr = "Fraction.", condition = in_mathzone, wordTrig = false, snippetType = "autosnippet"}, fmta([[\frac{<>}{<>}]], {i(1), i(2)}))

Basically, when I type () the cursor is positioned inside the parentheses. Then, if I type the \frac sequence, the parentheses are prepended, respectively, by the \left and \right directives; like this: \left(\right).

To insert the fraction directive \frac{}{} I have the // snippet. Unfortunately, when I type // inside the parentheses and the snippet is correctly expanded to \frac{}{}, the \left and \right directives don't appear immediately; I have to type something for luasnip to insert them.

I have read in the documentation that the function nodes are evaluated each time one of their arguments changes. Clearly, in this specific situation, this isn't happening.

micangl avatar May 28 '25 23:05 micangl