ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

Having issues installing #123

Open Orbyt opened 8 years ago

Orbyt commented 8 years ago

The github readme specifies installation via going into /Roaming/ST3/Packages and git cloning this repo, followed by npm install.

Now I'm not sure if installing via the package manager accomplishes the same as above, but i've also tried doing that.

Sometimes when trying from a clean insall, ill get the following: http://prntscr.com/ble0nx

Going to that directly and manually initiating the npm install seems to go through successful, but I am unable to get basic autocomplete working. I also noticed it often doesnt show up in package settings.

So what is the basic install process here? What am I missing?

zaynv commented 8 years ago
  1. Install tern_for_sublime through Package Control.
  2. Navigate to the tern_for_sublime folder in your Packages Directory.
  3. Inside that folder, run npm install

And you should be good to go.

Orbyt commented 8 years ago

Does not seem to work. npm install seems to go through fine, but theres no autocomplete. If I go to Sublime Text and start typing "require" I would assume an autocomplete option should pop up right? Because it doesnt. Also, for some reason 2 different Tern options appear in settings: http://prntscr.com/bnzs3d

zaynv commented 8 years ago

There are two tern plugins for Sublime. One is under the name of TernJS in Package Control and one is tern_for_sublime which is this one. I would recommend only using this one and removing the other package if you have it installed as well.

There won't be autocompletion for require, you can look into installing some other package for that like Nodejs. Tern does provide autocompletion for most other things that aren't Node-specific. To test if its working, try doing

[].

And you should get a tooltip for the available methods you can do on an array like so:

screen shot 2016-07-02 at 2 58 59 pm

It can also infer types:

screen shot 2016-07-02 at 3 00 33 pm

and if you use JSDoc, it can analyze that as well:

Example sum.js:

/**
 * Returns the sum of two operands
 * @param  {Number} a The first operand
 * @param  {Number} b The second operand
 * @return {Number}   The sum of both operands
 */
function sum (a, b) {
  return a + b
}

module.exports = sum
screen shot 2016-07-02 at 3 01 30 pm

You'll want to make sure you have the following in your user preferences:

{
  "auto_complete": true,
  "auto_complete_triggers": [ 
    {"selector": "text.html", "characters": "<"}, 
    {"selector": "source.js", "characters": "."} 
  ]
}