You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some configs snippet expansions I want to do would require expanding the placeholder inside of the eval expression. Would be possible to support that as a feature?
An example of what I'm trying to accomplish, basically to break the line automatically if I hit enter in the $2 placeholder.
snippet f "Anonymous function" i
function (${1})${2: }$3 `!lua "$2" == "\n" and "\n" or ""`end${0}
Ideas or possible solutions
I think it could maybe be solved by expanding $2 inside the string of the enclosed eval expression, but that would require re-evaluating the eval expression each time the placeholders are updated.
Alternatives you have considered
Alternatively, this could be exposed as a function call:
snippet f "Anonymous function" i
function (${1})${2: }$3 `!lua require("snippy").expand("$2") == "\n" and "\n" or ""`end${0}
The text was updated successfully, but these errors were encountered:
Looks like an interesting feature to add. Because Snippy uses luaeval() to handle Lua code, we could rely on the "magic" bult-in global _A, that works like this:
luaeval('_A[1] + _A[2]', [40, 2])
So we could have:
snippetf"Anonymous function"i
function (${1})${2:}$3`!lua _A[2] =="\n"and"\n"or""`end${0}
Problem Statement
Some configs snippet expansions I want to do would require expanding the placeholder inside of the eval expression. Would be possible to support that as a feature?
An example of what I'm trying to accomplish, basically to break the line automatically if I hit enter in the
$2
placeholder.Ideas or possible solutions
I think it could maybe be solved by expanding $2 inside the string of the enclosed eval expression, but that would require re-evaluating the eval expression each time the placeholders are updated.
Alternatives you have considered
Alternatively, this could be exposed as a function call:
The text was updated successfully, but these errors were encountered: