ternjs / tern_for_sublime

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

How to setup Tern for sublime for meteor.js #38

Closed tsega closed 10 years ago

tsega commented 10 years ago

I have been able to download and use _tern_forsublime and for vanilla JavaScript auto-completion and jump to definition works properly. In the tern_for_sublime package directory I've added a folder named plugins and added the meteor.js auto-completion plugin from Slava\tern-meteor.

In my meteor.js project, I have the following .tern-project file

 {
    "libs": ["browser", "underscore", "jquery"],
    "exclude": [".meteor/**", "node_modules/**"],
    "plugins": {
        "meteor": {}
    }
 }

So what I need help with is to check if the contents of this .tern-project file are correct and if what I've done by placing the meteor.js file in the package's folder also correct.

With this I'm able to see auto-completion but I'm unable to use the alt+. to jump to definition. I feel after two day of toiling with IDE's/Texteditors to fit my needs, I'm very close to solving my problem and I need your help to do that.

Thanks.

marijnh commented 10 years ago

I expect the meteor plugin isn't setting originNode properties on the nodes it produces. Why did you open this issue here, and not on the repository where the plugin actually lives?

tsega commented 10 years ago

@marijnh Thanks for the response. I asked this question here because the meteor plugin was actually made for the Emmet sublime tern project. For me that package did not work well, so I switched to yours. @slava my not know the details of how yours works so I opted to ask this question here.

Just to clarify on your suggestion, when you say "I expect the meteor plugin isn't setting originNode properties on the nodes it produces" do you mean as follows:


 "!define": {
      "IMeteor.absoluteUrl.options": {
        "secure": "bool",
        "replaceLocalhost": "bool",
        "rootUrl": "string",
        "originNode": "http://thedocs/url/for/this/node"
      },

If that's so I can actually do a pull request and try to contribute. Thanks again for the help.

Slava commented 10 years ago

Hmm, I think there is some misunderstanding going on.

@tsega, are you saying you can not jump to definition of Meteor symbols or any symbols? If Meteor symbols, then in fact it is because the plugin doesn't have originNode, that would cause your editor to jump to Meteor's code. If you meant jump to definition on any node, then it is not a problem of plugin as it was perfectly for me on vim with tern_for_vim.

tsega commented 10 years ago

@slava what you described above is exactly what's happening. To illustrate here is a sample client init.js file:

categories = new Meteor.Collection("categories");

categories.allow({
  insert: function(userId, doc){
    return Meteor.userId() ? true: false;
  },
  update: function(userId, doc){
    return Meteor.userId() ? true: false;
  },
  remove: function(userId, doc){
    return Meteor.userId() ? true: false;
  }
});

Now when I'm on line 1, on .Collection and hit the go to definition key combination alt+. I get a popup with the error message, could not find definition (happens with all other Meteor symbols) but if I'm on line 3 on "categories" and do the same thing I get moved to the definition of "categories" to line 1, which is what's supposed to happen.

So in short the plugin does need the originNode option as mentioned by @marijnh, so my last question really was how to add that to plugin.

marijnh commented 10 years ago

@tsega Jumping to code in libraries is not something that is supported at the moment (same for other plugins and the standard def files). You can add documentation links to this data by adding !doc properties. That might be what you want?

tsega commented 10 years ago

@marijnh and @Slava thanks guys for the help. I'm closing this issue and probably open a new one at Slava\tern-meteor