ternjs / tern_for_vim

Tern plugin for Vim
MIT License
1.83k stars 100 forks source link

TernDef command to go directly to the source #113

Closed danihodovic closed 9 years ago

danihodovic commented 9 years ago

If I have a file structure as such:

File foo.js

function foo() {}

module.exports = {
  foo: foo
};

File bar.js

var foo = require('foo')
foo.foo // call :TernDef here brings you to module.exports.foo instead of the source

Is it possible to go to the source function declaration instead of module.exports?

danihodovic commented 9 years ago

Also,

If module.exports are defined using the shorthand literal, tern can't find the original function even after calling :TernDef

function foo() {}

module.exports = {
  foo // :TernDef here won't take me to foo
}
marijnh commented 9 years ago

Nope, this isn't possible. Tern will take you to where the property you are looking at is defined. This is usually the right place, but as you found, sometimes it isn't optimal. Still, I am not aware of a good way to distinguish between these two types of situations.