ternjs / tern_for_sublime

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

Node plugin not properly working #29

Closed OliverJAsh closed 10 years ago

OliverJAsh commented 10 years ago

I have configured a small Node application to test the Node plugin. Here is my isolated case.

If I try to jump to the definition of a property on a dependency, i.e. require('./test').foo, Tern reports "Could not find a definition."

Autocompletion doesn't seem to work for the required module either (see index.js).

In spite of this, if I do require('util'), autocompletion does appear to work.

marijnh commented 10 years ago

The index.js in your tarball is a bunch of binary soup -- I guess something went wrong in uploading it.

OliverJAsh commented 10 years ago

My apologies. This one should work: http://cl.ly/2v1U3N0u1o1G/content

marijnh commented 10 years ago

Works for me. I created a .tern-project file that's just

{"plugins": {"node": true}}

If I open index.js in ST, hitting alt-. when the cursor is on foo takes me to the definition in test.js

OliverJAsh commented 10 years ago

Ahh, I had my .tern-project configured like so:

{
  "plugins": {
    "node": {
      "load": true
    }
  }
}

When it should actually be:

{
  "plugins": {
    "node": true
  }
}

It doesn't say anywhere in the documentation that this configuration is needed?

marijnh commented 10 years ago

The load option to the node plugin is a way to specify a regexp and tell the plugin to only load files that match it. Since true won't match very much ("x".match(true) is unfortunately not an error in JS), it won't load any files (unless you had one named "true").