Home Download Buy Blog Forum Support

TextMate Snippets - Completion not working

TextMate Snippets - Completion not working

Postby MMackus on Thu Aug 18, 2011 6:16 am

I added jquery textmate snippets to my packages directory. The snippets work fine in the "snippets" menu, but the one snippet I really want to use is the "$(document).ready(function() { });" snippet, the famous jquery main function. I type "ready" and hit tab, and, strangely, sublime changes ready to "already"! What is this? Some strange "spelling" completion? I also tried 'test' hit tab it expanded to 'tests'....
MMackus
 
Posts: 7
Joined: Thu Aug 18, 2011 6:14 am

Re: TextMate Snippets - Completion not working

Postby jps on Thu Aug 18, 2011 6:28 am

The jquery snippets have a selector of "source.js.jquery", which means they'll only trigger if you use the jquery .tmLanguage file from the same bundly (i.e., if your syntax needs to be set to "jQuery (JavaScript)".
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: TextMate Snippets - Completion not working

Postby MrMartineau on Sat Aug 20, 2011 6:33 am

Hey MMackus, I am in the process of porting the Textmate jQuery bundle to a Sublime package & you can download the latest on my Github page here: https://github.com/mrmartineau/jQuery-S ... xt-Package

I am also connverting the HTML5 Textmate bundle too (https://github.com/mrmartineau/HTML5-Su ... xt-Package) & have created a Placeholders package for lorem ipsum & dummy html (https://github.com/mrmartineau/Placeholders)

The HTML5 & jQuery packages are still not finished but you can use them without problem.
@MrMartineau || Setup Sublime Text quickly: Find out all you need at https://github.com/mrmartineau/SublimeTextSetup
MrMartineau
 
Posts: 78
Joined: Thu Jul 28, 2011 8:35 am

Re: TextMate Snippets - Completion not working

Postby nicktheandroid on Sat Aug 20, 2011 9:08 am

This is definitly something I expected to come already with Sublime. Even dreamweaver added Jquery to the default install. I think a lot of people would really appreciate that in the next build(or in a future build)(sooner the better), thanks!
nicktheandroid
 
Posts: 16
Joined: Tue Feb 08, 2011 5:33 pm

Re: TextMate Snippets - Completion not working

Postby MMackus on Tue Aug 23, 2011 4:18 pm

Thank you for your replies.

I was under the impression textmate snipplets were drop in functionality for Sublime - this is one of the main reasons I'm interesting in purchasing sublime. Perhaps I should look at something like E that has actual support for textmate snippets.

So, from what I understand, it needs to be in the correct scope. Not too big of a deal. Will other snippets work though? Such as PHP, etc?

RE: Github conversion - thats great, but I was hoping they would work out of the box. Thank you for the link though.

What about PHP, Python, and Ruby? I use those all the time...
MMackus
 
Posts: 7
Joined: Thu Aug 18, 2011 6:14 am

Re: TextMate Snippets - Completion not working

Postby adzenith on Tue Aug 23, 2011 11:08 pm

MMackus wrote:Thank you for your replies.

I was under the impression textmate snipplets were drop in functionality for Sublime - this is one of the main reasons I'm interesting in purchasing sublime. Perhaps I should look at something like E that has actual support for textmate snippets.

So, from what I understand, it needs to be in the correct scope. Not too big of a deal. Will other snippets work though? Such as PHP, etc?

RE: Github conversion - thats great, but I was hoping they would work out of the box. Thank you for the link though.

What about PHP, Python, and Ruby? I use those all the time...

As Sublimator said, they do work out of the box.
adzenith
 
Posts: 1215
Joined: Mon Oct 19, 2009 9:12 pm

Re: TextMate Snippets - Completion not working

Postby MMackus on Wed Aug 24, 2011 4:28 pm

Hmmm ok well the jquery snippets have a source.js.jquery scope right? How do I activate this scope? I'd rather this just be activated by default... I guess I could just do mass find->replace source.js.jquery. Is there a way to automatically activate this scope whenever I'm in a <script type="text/javascript"> block (or .js file)?

sublimator wrote:
jps wrote:The jquery snippets have a selector of "source.js.jquery", which means they'll only trigger if you use the jquery .tmLanguage file from the same bundly (i.e., if your syntax needs to be set to "jQuery (JavaScript)".


This is the reason why @MrMartineau thought it necessary to convert the snippets to `sublime-snippet` format. I see in the `conversion`they aren't scoped at all.

You just have to make sure you have the correct grammar applied. There's no real need to convert the snippets.


What do you mean by correct grammar?

Thanks guys, I'll try installing more snippets working tonight. Makes more sense now why the jquery ones didn't work.
MMackus
 
Posts: 7
Joined: Thu Aug 18, 2011 6:14 am

Re: TextMate Snippets - Completion not working

Postby aunderwo on Thu Sep 08, 2011 9:47 am

sublimator wrote:Someone mentioned, or showed code the other day that implied, that the <keyEquivalent> field in snippets now works in Sublime. This was never the case in S1. Can anyone confirm this?

I can't get this working. My snippet is as follows which is a direct copy of a TextMate Snippet. This aims for the # key to insert the charcaters #{} around text within a double quotes string. At the moment it does nothing. Any ideas??

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>content</key>
        <string>#{${1:$TM_SELECTED_TEXT}}</string>
        <key>keyEquivalent</key>
        <string>#</string>
        <key>name</key>
        <string>Embedded Code — #{…}</string>
        <key>scope</key>
        <string>(string.quoted.double.ruby|string.interpolated.ruby) - string source</string>
        <key>uuid</key>
        <string>12F6DE4C-6981-4413-8582-C0286D2ED84B</string>
</dict>
</plist>
aunderwo
 
Posts: 7
Joined: Thu Sep 08, 2011 9:40 am

Next

Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 7 guests