-
Notifications
You must be signed in to change notification settings - Fork 102
Dropdown/Autocomplete inside snippets #186
Comments
would be nice |
👍 This would make snippets so much more useful! |
👍 |
This would be amazing, add me to the 👍 |
Our team really need this feature, it's like npp fingerText plugin |
PyCharm Templates can do this, this is why I was looking for an open feature request here, since I currently evaluate Atom as an alternative to PyCharm. :) 👍 <template name="req" value="- require: - $TYPE$: $RESOURCE$ $END$" description="Salt Requisite require statement" toReformat="false" toShortenFQNames="true">
<variable name="TYPE" expression="enum("sls","pkg","file","service","cmd","test","user","group","host","mount","ssh_auth")" defaultValue="" alwaysStopAt="true" />
<variable name="RESOURCE" expression="clipboard()" defaultValue="" alwaysStopAt="true" />
<context>
<option name="OTHER" value="true" />
</context>
</template> Of course PyCharm templates are hard to read, sorry it's java and java loves XML xD PS: Filling in the contents of the clipboard (also shown in my example) would be also very nice, although the enum is much more important in my opinion. here is a preview of some snippets for saltstack I'm working on: https://git.finchi.de/snippets/2/raw |
Awesome feature |
FYI autocomplete-html already does this. Is there any reason to keep this issue open since autocomplete and ide packages can provide snippet autocompletion without complicating the snippet syntax? |
@50Wliu I think definitely there is reason to keep it open. To be sure, the existing autocomplete is very useful. I use it a great deal when using snippets. However, with the existing autocomplete, you have to start typing, and the results are everything autocomplete knows about that's in scope. With what's suggested here, the list is specific and custom to the snippet, and only shows that. Beyond that, the example screenshot above shows the first item highlighted by default, which would be great, too. You can type whatever, or hit tab again to accept the default, or arrow and hit tab to accept one of the other enumerated values. With the current autocomplete, you have to start typing a bit before you start to get things you want. Another reason is that you may want to have a enumeration that autocomplete just won't have the proper suggestions for (see the below example). If I create a snippet and want the options to be 'apple', 'ball', and 'carrot', I may want to always see those and only those for a particular tab stop in my custom snippet. I think what's being asked for here is the ability to control what shows in the autocomplete. And I would suggest that it would be great to allow for something like:
I frequently use the same number multiple places in my snippets where I need the same string inserted, and having trailing instances respect the first enumerated one still would be important behavior to preserve. re: complicating the snippet syntax, I don't think that's an issue. Adding support for an additional bit of syntax doesn't complicate existing simpler snippets. I think a section at the bottom of the docs that says something like "and if you want to put an enum in a particular $'d tab stop, here's how you'd do that" would be simple enough. I don't think that would confuse anyone, especially forthose who don't end up using it. (How it plays out in the actual snippet parsing code would certainly be more complex, but that's a separate concern from snippet syntax for the user.) |
VScode has implemented this; see the “Choice” heading in this documentation. If we add this in the future we should aim for syntax compatibility unless we have an excellent reason not to. |
Atom and I guess also Sublime missing dynamic snippet, NP++ plugin fingertext is powerful snippet plugin which support, FILE, DATE, LIST, OPTION, EXEC, RUN and many other dynamic feature, seems like its hard for them to implement this request ;) |
see https://macromates.com/textmate/manual/snippets#grammar too.
|
If VSCode and TextMate both share the same syntax for this feature, I think it makes all the sense in the world to follow suit. It also makes sense if multiple other editors support the feature to add it to Atom so it's not lagging behind. |
Hi,
It may be useful to use dropdown list inside snippets placeholder as textmate does.
Let's say I create a snippet for the HTML
<input>
element.That would be really powerful if I was able to write it like this ;
and use it like that :
I don't know how feasible it is, but it would be really convenient, at least for a bunch of my snippets, for a lot of HTML snippets, Laravel snippets and a lot of methods which signature change depending on the context.
Whether you consider my enhancement proposition or not, I'd like to thank you all for this awesome editor.
Atom Version: 1.2.4
OS and Version: OSX 10.11.1
The text was updated successfully, but these errors were encountered: