Replies: 2 comments 6 replies
-
Oh, nice, that's definitely possible. I'll list some ingredients :D
Alternative approach: wrap the entire snippet in a dynamicNode which checks if there was selected text, and returns one or the other (could also be used for postfix, by checking its variable as well) Oh or!: use |
Beta Was this translation helpful? Give feedback.
6 replies
-
For completeness, here's the postfix version: require("luasnip.extras.postfix").postfix(".printv", {
t("print(\""),
l(l.POSTFIX_MATCH),
t("=\\("),
l(l.POSTFIX_MATCH),
t(")\")"),
i(0)
}), |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Let's say I have a Swift snippet called
printv
, with the end result looking like this:I want to be able to use it three separate ways:
You type
printv
on an empty line and it expands to let you type in the name of the variable, which it then duplicates.2. With selection
Select an expression (e.g.,
viw
), hit Tab (in my case, since), then type
printv
and it will fill in the selection.3. Postfix
I haven't written it yet, but I don't think it will be too complicated.
My question is about trying to get only one of these to show up at a time. If you type
printv
on a blank line, bothprintv-standalone
andprintv-selection
show up. I'd like to have them set up so that, ifTM_SELECTED_TEXT
is empty, I only seeprintv-standalone
, and ifTM_SELECTED_TEXT
has a value, I only seeprintv-selection
. I'm not sure exactly how a postfix version will fit into the mix, because I haven't written that yet either, but I'd like it to also be disambiguated.Is this possible?
Beta Was this translation helpful? Give feedback.
All reactions