Home Download Buy Blog Forum Support

How to use jQuery snippets?

Re: How to use jQuery snippets?

Postby qqq on Tue Mar 08, 2011 2:25 pm

Win7/ST2(b. 2042) issue

After having read this topic and having tried a couple of things I am still not able to get jQuery to work in Sublime Text 2.

I want
1) jQuery appearing in Snippets menu (optional)
2) jQuery appearing in Syntax menu
3) be able to add working <tabTrigger> snippets

I have:

a) put the snippets downloaded from http://sublime.akalias.net/snippets/Jav ... %20jQuery/ in my %AppData%\Sublime Text 2\Packages\Javascript folder
b) put the language file downloade from https://bitbucket.org/sublimator/jquery ... tmLanguage in the same folder

The result is:
ad 1) jQuery does not appear in Snippets menu (this is probably because all the snippets were put in the JavaScript folder)
ad 2) ok - jQuery appears in Syntax menu
ad 3) some bizzare things happen, for example:
The snippet <tabTrigger>.end</tabTrigger> won't work. However if I remove the dot making it <tabTrigger>end</tabTrigger> it works just fine! This happens with all the triggers that start with a dot (and most of them do). The <tabTrigger>$</tabTrigger> also does not work and it won't until it starts with $. Tried some other combination and it seems that a trigger that doesn't start with an alphanumerical character (numbers are ok) can't be made to work. Can you explain this?
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: How to use jQuery snippets?

Postby tstrokes on Tue Mar 08, 2011 5:58 pm

1) jQuery appearing in Snippets menu (optional)
2) jQuery appearing in Syntax menu
You can create a first level menu item in both menus by creating a jQuery folder in the packages directory.
Then copy over the jQuery.tmLanguage and all snippets. This however is not the preferred way.
Using the user directory in the packages directory is better because these files won't get wiped away when you upgrade ST.
This will however create a second level menu in the snippets menu under User and a first level menu in the Syntax menu.

3) be able to add working <tabTrigger> snippets
This is a bug: viewtopic.php?f=2&t=1820&start=40#p8394
tstrokes
 
Posts: 17
Joined: Wed Dec 03, 2008 6:39 pm

Re: How to use jQuery snippets?

Postby qqq on Tue Mar 08, 2011 6:55 pm

Thanks @tstrokes.

However neither of your solutions solved the problem completely:

-On ST startup I get an error message "Error loading syntax file "Packages/XML/XML.tmLanguage": Error parsing plist xml: Failed to open file In file "Packages/JavaScript/jQuery.tmLanguage",
-There is neither "User" no "jQuery" in Syntax menu (Snippet menu ok),
-And I would like .js files to be in the scope of both JavaScript and jQuery. Maybe it would be the case if I was able to select "jQuery" from Syntax menu. But with "JavaScript" selected only JavaScripts snippet work.

The makeshift solution I have found is to have snippets+tmLanguage file both in JavaScript folder and in a separate jQuery folder (either in Packages or in Packages\User). This way it works, but I don't think it is a preferred solution as it should be managed by the scope, copying the same files in several different places is simply not elegant
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: How to use jQuery snippets?

Postby qqq on Tue Mar 08, 2011 7:37 pm

SOLVED! (my sloppy reading!) :geek: :geek: :geek: :geek: :geek:

But I'll try to summarize it here for the posterity:

1) download jQuery snippets from: http://sublime.akalias.net/snippets/Jav ... %20jQuery/
2) download a jQuery.tmLanguage file from: https://bitbucket.org/sublimator/jquery ... tmLanguage
3) put the files you have downloaded in 1) and 2) in:
a) either Packages\jQuery folder (this folder is located in %appdata%\Sublime Text 2\)
b) or Packages\User\jQuery folder (recommended, as this location is not overwritten when software is upgraded),
4) edit the file you have downloaded in 2) (jQuery.tmLanguage): it needs at least one fileTypes entry, in case it hasn't:
Enter the following code at line 7 and save changes:
Code: Select all
   <key>fileTypes</key>
   <array>
      <string>js</string>
   </array>

P.S. At the moment there is a problem with snippets whose triggers contain non-alphanumerical signs (they do not work) so don't freak out. Probably by the time most of you read this it will be fixed.
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: How to use jQuery snippets?

Postby gellpak on Mon Apr 11, 2011 2:40 pm

qqq wrote:SOLVED! (my sloppy reading!) :geek: :geek: :geek: :geek: :geek:

But I'll try to summarize it here for the posterity:

1) download jQuery snippets from: http://sublime.akalias.net/snippets/Jav ... %20jQuery/
2) download a jQuery.tmLanguage file from: https://bitbucket.org/sublimator/jquery ... tmLanguage
3) put the files you have downloaded in 1) and 2) in:
a) either Packages\jQuery folder (this folder is located in %appdata%\Sublime Text 2\)
b) or Packages\User\jQuery folder (recommended, as this location is not overwritten when software is upgraded),
4) edit the file you have downloaded in 2) (jQuery.tmLanguage): it needs at least one fileTypes entry, in case it hasn't:
Enter the following code at line 7 and save changes:
Code: Select all
   <key>fileTypes</key>
   <array>
      <string>js</string>
   </array>

P.S. At the moment there is a problem with snippets whose triggers contain non-alphanumerical signs (they do not work) so don't freak out. Probably by the time most of you read this it will be fixed.


Mac OS X 10.6.7

I've followed this guide and manually downloaded the packages into my ~/Library/Application Support/Sublime Text 2/Packages/ folder, making sure to rename the folders with the proper capitalization, but can't get any autocomplete working. jQuery shows up in both the Syntax menus and Snippets menus, and when I select jQuery as my syntax, the color highlighting on my code changes slightly. However, my tests of "$ > [tab]" or "this > [tab]" have no effect, I just end up with exactly what I typed. I can manually go into the menus and trigger a snippet. Tried erasing the Sublime Text 2 library folder and restarting all of this but that had no effect either. Help?
gellpak
 
Posts: 1
Joined: Mon Apr 11, 2011 2:35 pm

Re: How to use jQuery snippets?

Postby whololo on Fri Jan 13, 2012 9:27 am

P.S. At the moment there is a problem with snippets whose triggers contain non-alphanumerical signs (they do not work) so don't freak out. Probably by the time most of you read this it will be fixed.[/quote]

I think triggers with $ is still not possible.
whololo
 
Posts: 12
Joined: Fri Jul 08, 2011 10:47 am

Previous

Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot] and 10 guests