Home Download Buy Blog Forum Support

How to use jQuery snippets?

Re: HOW TO USE JQUERY SNIPPETS?????????????????

Postby jps on Wed Feb 09, 2011 4:26 am

A .tmLanguage file needs at least one fileType entry to appear in the list of available syntaxes in Sublime Text
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: How to use jQuery snippets?

Postby nicktheandroid on Fri Feb 11, 2011 9:39 am

I'm sorry maybe i'm a little dull, but i downloaded the .zip from the bitbucket link you posted. then in S2 I went to 'preferences' > 'browse packages' then when the folder opened, i stuck the jquery folder i downloaded in there with all the other folders. i reset S2, and I see Jquery in the snippets menu, but not in the syntax menu, i even scrolled all the way down, and pressed J to scroll through all those starting with J.

Was it supposed to work after doing that?

WindowsXP 32bit
nicktheandroid
 
Posts: 16
Joined: Tue Feb 08, 2011 5:33 pm

Re: How to use jQuery snippets?

Postby nicktheandroid on Fri Feb 11, 2011 11:22 am

Just tried deleting the cache file, and it's still not showing up inside the syntax menu under 'tools'. I searched Google for the textmate folder with snippets and all that stuff that's in your download link, and i tried that too, and when i added that one it had the 't.h.i.s TAB' stuff in the snippets menu next to the snippet, which isn't there when i use the one you put a link to. But either way it's still not in the syntax menu. Is there a way to make jquery work under the javascript syntax? or? i'm just trying to find any way to make jquery syntax work, sublime is no good to me if I can't get this working. It works in E text-editor, but development over there seems dead and there's a few problems that haven't been taken care of and it's been too long.

I'm using Sublime 2 Build 2020 on windowsXP 32bit
nicktheandroid
 
Posts: 16
Joined: Tue Feb 08, 2011 5:33 pm

Re: How to use jQuery snippets?

Postby jps on Fri Feb 11, 2011 12:13 pm

Check that:

A) You have a .tmLanguage file for jQuery
B) Inside the .tmLanguage file, it has one or more entries in the <fileTypes> array
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: How to use jQuery snippets?

Postby nicktheandroid on Sat Feb 12, 2011 3:51 am

jps wrote:Check that:

A) You have a .tmLanguage file for jQuery
B) Inside the .tmLanguage file, it has one or more entries in the <fileTypes> array


PERFECT, there was no <fileTypes>, so i copied it from the javascript package and now jquery shows up in the syntax list. How did it work for you subliminator if you didn't have the <fileTypes> line in your language file? Also, in the package you put online, there's no tabTrigger in any of the .sublime-snippet files. Does your converter keep the tab trigger? because looking through it, none of the snippets in the package you put online have tabTriggers. I added a few tab triggers to see if jquery works, and i finally got it working after adding the <fileTypes> line, and then adding <tabTrigger>trigger word</tabTrigger> to each snippet.
nicktheandroid
 
Posts: 16
Joined: Tue Feb 08, 2011 5:33 pm

Re: How to use jQuery snippets?

Postby nicktheandroid on Sat Feb 12, 2011 4:44 am

so, i can copy what you posted right there, copy that into the keymap file and it will take the name of the snippet and make that the tab trigger?
nicktheandroid
 
Posts: 16
Joined: Tue Feb 08, 2011 5:33 pm

Re: How to use jQuery snippets?

Postby atomi on Wed Mar 02, 2011 12:50 am

Why not use the tabTrigger?

It seems messy to pollute the user's .sublime-keymap file.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: How to use jQuery snippets?

Postby atomi on Wed Mar 02, 2011 4:15 pm

You're probably aware of this, but just to be sure, you can confine all package specific bindings to a relevant keymap


I actually wasn't aware of that -I hadn't seen this in any of the current Packages.

Thanks for taking the time to explain your process.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: How to use jQuery snippets?

Postby atomi on Wed Mar 02, 2011 5:38 pm

Luckily I wrote a bindings/commands converter the other week for ZenCoding so it's a 10 second job to convert the jQuery folder.


That sounds cool and useful.
Have you made this converter available publicly?

Also,
If for whatever reason you want to use binding contexts other than just a <scope> selector or you want to use regex bindings (not yet in S2) you can't use <tabTrigger>
If for some reason you've written a plugin command (preserving relative indentation of $SELECTION etc) that adds extra functionality surrounding inserting snippets you can't use <tabTrigger>
If you have a few k snippets, it's a lot quicker to parse key map files to get an aggregate list of bindings, without having to track modifications.


Do these restrictions apply to the sublime-completions method as well?
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: How to use jQuery snippets?

Postby atomi on Thu Mar 03, 2011 9:10 am

...if there's a way to record 'b' as yielding 'both' and 'bottom' in different circumstances.


Well yeah, and 'block' too. :)

Of course it'd be great to have context based completions.
My problem is there isn't a concrete commitment to one particular method as far as I can tell.

It seems to me, being on the periphery of things, that sublime-completions is where further development is going to take place in regards to specific context completions. And if there are limitations to using sublime-completions file for describing tab targets, I'd love for them to outlined and addressed.

I don't mind scripting a quick and dirty converter for either sublime-keymaps or sublime-completions, but I'd like to do it for at least the one that promises to provide the most features (in case the snippets need refinement as you've mentioned).

On the other hand, if the only way to improve snippet behavior will be through a plugin, then the method of defining the snippet is irrelevant, so long as Sublime is able to find it. If that also means that a sublime-keymaps file is the best method of accessing the tab target information for fancy context based snippet plugin, I guess that's fine too.

But this architecture needs to be figured out and promoted.

Anyway, good to hear your thoughts on this.
Thanks again.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

PreviousNext

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 16 guests