Home Download Buy Blog Forum Support

jQuery autocomplete/code intelligence?

jQuery autocomplete/code intelligence?

Postby CaptSaltyJack on Tue Feb 28, 2012 7:08 pm

Surely this must be simple. I'm looking for a way to have Sublime allow jQuery auto completion as well as code intelligence (knowing parameters for jQuery methods, etc). Is this doable?

Thanks.
CaptSaltyJack
 
Posts: 6
Joined: Tue Feb 28, 2012 7:06 pm

Re: jQuery autocomplete/code intelligence?

Postby agibsonsw on Tue Feb 28, 2012 7:57 pm

A quick google reveals a number of plug-ins for jQuery, including this one.

The Package Control plug-in will probably help you to install a jQuery plug-in. Otherwise, you could create a folder named 'jQuery' (in your 'Packages' folder) and copy a number of files/snippets to it.

The jQuery snippets/completions will probably display for any .js file, but I suppose if you're using jQuery you're likely to be using it most of the time anyway ;)
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: jQuery autocomplete/code intelligence?

Postby CaptSaltyJack on Tue Feb 28, 2012 11:19 pm

Wait, I'm confused. I have this jQuery folder in ~/.config/sublime-text-2/Packages. It has all the autocompletes, etc. I just don't know how to activate it.
CaptSaltyJack
 
Posts: 6
Joined: Tue Feb 28, 2012 7:06 pm

Re: jQuery autocomplete/code intelligence?

Postby agibsonsw on Tue Feb 28, 2012 11:44 pm

CaptSaltyJack wrote:Wait, I'm confused. I have this jQuery folder in ~/.config/sublime-text-2/Packages. It has all the autocompletes, etc. I just don't know how to activate it.


Mmmm.. not sure. Check your File Settings - Default for:
Code: Select all
   // When enabled, pressing tab will insert the best matching completion.
   // When disabled, tab will only trigger snippets or insert a tab.
   // Shift+tab can be used to insert an explicit tab when tab_completion is
   // enabled.
   "tab_completion": true,

   // Enable auto complete to be triggered automatically when typing.
   "auto_complete": true,

Try pressing Ctrl-Space to see if this displays completions for you. Perhaps check the completions file itself to see if it has a line like:

Code: Select all
"scope": "source.js -string -comment -constant",
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: jQuery autocomplete/code intelligence?

Postby Graham on Wed Feb 29, 2012 2:37 am

I have this plug in too, but no auto-complete for even simple things like .click.
Graham
 
Posts: 4
Joined: Wed Feb 29, 2012 2:17 am

Re: jQuery autocomplete/code intelligence?

Postby wbond on Wed Feb 29, 2012 2:57 am

From looking over the plugin, it provides a syntax file for jQuery and a bunch of snippets. I do not see a .sublime-completions file, which is what I believe is used to power the autocomplete functionality.
wbond
 
Posts: 523
Joined: Mon Feb 28, 2011 5:33 am

Re: jQuery autocomplete/code intelligence?

Postby C0D312 on Wed Feb 29, 2012 3:07 am

wbond wrote:From looking over the plugin, it provides a syntax file for jQuery and a bunch of snippets. I do not see a .sublime-completions file, which is what I believe is used to power the autocomplete functionality.


Well, ST2 does add snippets to the autocompletion, but that could hardly be comparable to code intelligence.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: jQuery autocomplete/code intelligence?

Postby CaptSaltyJack on Thu Mar 01, 2012 1:26 am

Ok, looks like there is sort of completion. If I do $.getJSON then hit tab, it fills out the possible parameters which is nice. But it doesn't have the same level of autocomplete as you're typing, like it does in PHP which is quite extensive, i.e., as I'm typing $.getJ... it doesn't pop up a list of possible methods.

Needs work. This is the mrmartineau jQuery package BTW.
CaptSaltyJack
 
Posts: 6
Joined: Tue Feb 28, 2012 7:06 pm

Re: jQuery autocomplete/code intelligence?

Postby midtone on Thu Mar 01, 2012 6:20 pm

Coda has a great plug in that auto completes nearly everything jQuery. I want to like Sublime. I do. But it seems like I am repeatedly going back to Coda for the features I need and want....
midtone
 
Posts: 2
Joined: Tue Feb 21, 2012 5:35 am

Re: jQuery autocomplete/code intelligence?

Postby nicktheandroid on Fri Apr 20, 2012 1:44 am

I'm trying to accomplish this too. I did the package control thing and got jquery with the TONS of snippets, but it has no code completion while typing, so typing $().add should bring up the white menu showing me .addClass(), without me having to do anything, then I could press tab to select that autocomplete choice

From reading above, it looks like there needs to be a .sublime-completion file, and without that file for jquery, it wont work?
I thought that downloading the jquery snippets pack from package control would add those to the "autocomplete that pops up while typing".

Hitting ctrl+space to bring up the white autocomplete box just slows the whole process down.
nicktheandroid
 
Posts: 16
Joined: Tue Feb 08, 2011 5:33 pm

Next

Return to Technical Support

Who is online

Users browsing this forum: OJFord and 12 guests