Home Download Buy Blog Forum Support

jQuery autocomplete/code intelligence?

Re: jQuery autocomplete/code intelligence?

Postby agibsonsw on Fri Apr 20, 2012 11:25 pm

Creating a completions file for jQuery is fairly straight-forward, although I think I discovered one on the interweb that just needs updating - I'll have to look again.

The basic structure is like this, saved as jQuery.sublime-completions:

Code: Select all
   "scope": "source.js -string -comment -constant",

   "completions": [
      { "trigger": ".add()", "contents": ".add($1)$0" },
      { "trigger": ".slideToggle()", "contents": ".slideToggle(${1:duration}, ${2:easing}${3:[, callback]})$0" }

The add version would allow you to tab into the brackets. slideToggle would allow tabbing between the arguments, and I generally leave the square brackets [, and an extra comma] to indicate that it's optional. This means that, when tabbing, I can either press Delete or re-enter the comma and space (and the argument), before tabbing out.

It would also require creating the setting to allow the dot as a trigger-character, assuming this is required:

Code: Select all
    // Additional situations to trigger auto complete
    "auto_complete_triggers": [ {"selector": "source.js", "characters": "."} ] // or \.

I might try and find the page I mentioned, or perhaps someone has discovered a web-page that lists the jQuery methods in a table column that I can copy? But I won't be doing this for a few days as I'm otherwise occupied.

"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 24 guests