Sublime Forum

Dev Build 2030

#11

I second that request. I use the Codeigniter style too.

0 Likes

#12

The specific issue is that PHP snippets won’t trigger at EOF, because the selector won’t match there (the reported scope is always text.html.basic at EOF in a PHP file). I’ll fix this for the next build.

The rules for when snippet fields are cancelled aren’t great from a usability POV: they appear to stick around for too long. There’s good reasons for why they act like they do, but it’s something I need to address. In the mean time you can press escape to cancel all the snippet fields.

It’s coming, but in the mean time there’s a way to create a file in a specific directory: when creating a new file via Ctrl+N, it’ll save by default to the directory of the last file you used. Open a file in the directory of interest, then hit Ctrl+N, then Ctrl+S, and you’ll be in the right spot.

When I first implemented it, snippets used fuzzy matching on the tab trigger. I didn’t particularly like it, because I kept getting snippets unexpectedly inserted when I was just trying to complete a word. I think there’s some justification for this: snippets already tend to have short tab triggers, and a snippet often isn’t really a word completion target, but a code generation mnemonic.

For example, if I have a python function with a function called ‘classify’, it’s likely typing cls,tab means I want to insert ‘classify’, rather than generate a class template.

0 Likes

[BUG] Scope selector fails when cursor in a very end of file
#13

Great news, thanks again for all the hard work man!

0 Likes

#14

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.

0 Likes

#15

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.

0 Likes

#16

Dev Build 2031 is out now with a few tweaks.

0 Likes

#17

Dev download links aren’t updated yet. :smile:

0 Likes

#18

Fixed now, cheers

0 Likes

#19

Just noticed the PHP fixes in 2031, thanks for the quick turnaround :smile: will test now.

0 Likes

#20

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?

0 Likes

#21

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.

0 Likes

#22

Started on a C completions file @ bitbucket.org/asmodai/sublimetext

0 Likes

#23

Awesome! Thanks. :smile:

0 Likes

#24

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):wink:

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.

0 Likes

#25

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.

0 Likes

#26

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)

0 Likes

#27

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.

0 Likes

#28

[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.

0 Likes

#29

This snippet window doesn’t seem to constrain itself to my screen: the bottom easily gets cut off.

0 Likes

#30

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 :smile: Great stuff.
CSS-completions.zip (2.65 KB)

0 Likes