This is great! Iāve been waiting for the auto-complete feature! Komodo Editor has itās source code open and includes some nice code intelligence under an Mozilla license I was hoping someone or me could port to sublime ā¦to that, is there anyway we can bind the auto-complete to other keys in a per-language basis? ā¦like for instance for some languages bind on using dot, for some on using ->, for some others, like python, on using both dot and also space under certain circumstances (i.e. when you use space after āimportā or āfromā) ā¦as to show auto-complete for class members and attributes, and for modules that can be currently imported and so on. As to make auto-completion as fluid as just simply writing code and so it just pops up whenever something is available as you write code.
Dev Build 2030
There seems to be a bug with autocomplete in PHP at least, trying to complete all functions when prefixing with $. If the first letter of the word is $, autocomplete should only look for variable words, not function words. Just type $u <ctrl+space> and you get tons of results that shouldnāt be there.
Just noticed the PHP fixes in 2031, thanks for the quick turnaround will test now.
Jon, the completion stuff, parameters need to be provided in descending order? I.e.:
contents: "test($1, $0)"
instead of
contents: "test($0, $1)"
At least, the former works for me, not the latter. Is that by design?
The order is $1, $2, $3, ā¦, $0 - itās a TextMate-ism. Furthermore, if $0 isnāt present in the snippet, itāll be implicitly added to the end.
Can I ask how exactly would this be best implemented?
For example I see a snippet for require:
<snippet>
<content><![CDATA[require '${1:file}';$0]]></content>
<tabTrigger>req</tabTrigger>
<scope>source.php</scope>
<description>require ā¦</description>
</snippet>
All well and done, however how can I get the require snippet to only expand if the auto-completed valued is require()? Because the tabTrigger for all the array_* functions would be the full function, but then to get the benefit of the snippet the user would have to do:
array_w (expands to array_walk(|))
(now array_walk|)
(now array_walk(|$array, $funcname)
I can provide the snippets without problem, but is there a way they will be smart about not requiring the + step?
EDIT
Here is a PHP.sublime-completions that has been updated from php.net today, omitting Class references (as is in the original file) and with proper argument counts for every function: bitbucket.org/vostok4/sublimeph ā¦ ompletions Feel free to include it in ST2 if you like, or if we figure out the snippets Iāll provide all that code instead.
PHP.sublime-completions accepts the full snippet syntax in the contents field, so you can put in ā$array_walk(${1:array}, ${0:funcname})ā, for example.
Thanks for all your hard work jps, this is definitely looking impressive!
Since weāre on the subject of snippets etc, is there currently a UI available - or planned to be implemented - for me to view available snippets within a given snippet directory?
i.e. When Iām working inside PHP tags, Iād like a quick reference panel (perhaps located underneath the minimap?) where I can see a preview of PHP snippets and their associated trigger. I can then double click an item to insert, or enter the tab trigger, even right click for a context menu that allows me to edit the snippet contents, change the tab trigger, or remove the snippet completely. Being able to switch between snippet views quickly and painlessly would be nice, even dynamically updating the snippet panel when moving between different code sections within the same file (e.g. PHP <-> HTML / Javascript <-> HTML)
While not exactly what youāre after, pressing ctrl+space without typing anything (i.e., with only whitespace or punctuation to the left of the cursor) will show a list with of valid snippets at that point.
[quote=āskaetā]Thanks for all your hard work jps, this is definitely looking impressive!
Since weāre on the subject of snippets etc, is there currently a UI available - or planned to be implemented - for me to view available snippets within a given snippet directory?
i.e. When Iām working inside PHP tags, Iād like a quick reference panel (perhaps located underneath the minimap?) where I can see a preview of PHP snippets and their associated trigger. I can then double click an item to insert, or enter the tab trigger, even right click for a context menu that allows me to edit the snippet contents, change the tab trigger, or remove the snippet completely. Being able to switch between snippet views quickly and painlessly would be nice, even dynamically updating the snippet panel when moving between different code sections within the same file (e.g. PHP <-> HTML / Javascript <-> HTML)[/quote]
I think the zen coding method of pressing F1 to bring up a find panel style list of all possible snippets in the current syntax would be better. Rather than having a panel always on screen.
This snippet window doesnāt seem to constrain itself to my screen: the bottom easily gets cut off.
Iāve made a file for CSS completions based on this properties list meiert.com/en/indices/css-properties/. Itās just a basic start for all the properties I havenāt added variations of each property with completed values. Iāve commented out the CSS3 elements I donāt think any browser supports yet but I could be wrong on a few (voice perhaps). Feel free to include it in Sublime and change or modify it.
Btw, the fuzzy completions are great! Itās like zen coding but i can make up the completion snippet based on what makes sense Great stuff.
CSS-completions.zip (2.65 KB)
So with the new auto completions is there a possibility of a āDisplay auto completion as you typeā setting?
Jon,
have you given thought to conditional completions? E.g. in C only allow certain completions if an #include <ā¦> for that part is present. I can see that I need to provide C_completions.py for the parsing and such, but does the completions file allow for any demarking of the appropriate sections?
Not sure if it has been reported in this thread yet, just skimmed through it quickly and it seems kinda crazy to make a separate thread for it so just posting a bug I found here. I tested it in PHP and it didnāt occur so I think itās only an HTML issue but for some reason in HTML the following occurs.
[code]
Some text.
A test.
[cursor here] [/code]Now if the cursor is where itās shown above and you hold shift then up then end to delete the second paragraph, ST2 unindents the first paragraph for some reason. On Linux if itās platform specific for some reason.
[code]
Some text.
[/code]