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
I have a proposal for supporting placeholders nested inside optional placeholders. This may be hard to explain so please bear with me.
Consider the following example snippet (I have a minimal example later on, but this one is practical):
snippet forEach
alias each
regexp '\.'
options word
forEach((${1:value}${2:#:, ${3:key\}}) => {
${4}
});${0}
The goal of this is that the text , key is optional, but the complication is that the important part of , key is the inner placeholder, key, which should be able to be changed or referenced. Another way of explaining this is that placeholder 3 is optional, but placeholder 2 should be removed if 3 is unchanged.
I think the best way to support this would be to modify what happens on expansion/jump of an optional placeholder. If nothing was changed on expansion, instead of removing the placeholder look to see if there is another placeholder inside it. If you jump away from the inner placeholder without changing, the outer one would be removed. If you change an inner placeholder, both would be kept. If this were the case, my above example would remove the key default text inside 3, as it would no longer make sense (or it could be left for visual reference, but would be removed if unchanged).
The following is a minimal example that my proposal would handle. Hello! would be printed if you jump over 1 and 2, and Hello, world! would be printed if you jump to 1 and 2 to type world.
snippet nest
Hello${1:#:, ${2\}}!
I realize this sounds complicated, and maybe too complicated to add. I would encourage you to ask me for clarification if my proposal does not make sense. I would also like to mention that this is actually supported with Sublime Text (and therefore TextMate) snippets, in that you could just hit <backspace> on a snippet to delete it and continue to the following placeholders. In neosnippet.vim, however, manually deleting a placeholder screws up the jumping order. Maybe that should be called out as a separate issue.
The text was updated successfully, but these errors were encountered:
Right now, jumping over an optional placeholder removes it, no matter what is inside. Thus nested placeholders only do something when the outer placeholder is not optional.
I am proposing that if there is a placeholder within an optional placeholder, the optional one is only removed if the inner placeholders are jumped over as well.
I have a proposal for supporting placeholders nested inside optional placeholders. This may be hard to explain so please bear with me.
Consider the following example snippet (I have a minimal example later on, but this one is practical):
The goal of this is that the text
, key
is optional, but the complication is that the important part of, key
is the inner placeholder,key
, which should be able to be changed or referenced. Another way of explaining this is that placeholder3
is optional, but placeholder2
should be removed if3
is unchanged.I think the best way to support this would be to modify what happens on expansion/jump of an optional placeholder. If nothing was changed on expansion, instead of removing the placeholder look to see if there is another placeholder inside it. If you jump away from the inner placeholder without changing, the outer one would be removed. If you change an inner placeholder, both would be kept. If this were the case, my above example would remove the
key
default text inside3
, as it would no longer make sense (or it could be left for visual reference, but would be removed if unchanged).The following is a minimal example that my proposal would handle.
Hello!
would be printed if you jump over1
and2
, andHello, world!
would be printed if you jump to1
and2
to typeworld
.I realize this sounds complicated, and maybe too complicated to add. I would encourage you to ask me for clarification if my proposal does not make sense. I would also like to mention that this is actually supported with Sublime Text (and therefore TextMate) snippets, in that you could just hit
<backspace>
on a snippet to delete it and continue to the following placeholders. Inneosnippet.vim
, however, manually deleting a placeholder screws up the jumping order. Maybe that should be called out as a separate issue.The text was updated successfully, but these errors were encountered: