ternjs / tern_for_sublime

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

Does it work for sublime text 3? #95

Closed nkapatos closed 8 years ago

nkapatos commented 9 years ago

Hello

I have followed the steps as described (including the fix path for mac) but no tooltips, no autocomplete and not even goto definition for methods defined in the project (the default right click goto definition does work). I do not know if it makes any difference but I couldn't install the plugin from the sublime popup after cloning the project into the packages folder. I did the manual npm install. I have also installed tern globally and even started it manually just in case I am missing something but no change. There are no errors in the console, I have added the autocomplete to fire on dot and tried with the example of document.addEven, I have tried in different js files (node, vanilla js, jQuery) with different patterns just in case.

Is there something missing in the process or something that has to be done before using the plugin? Like manually indexing the project files?

Thank you

EDIT: 1 - I am using emmet which I uninstalled but still nothing changed 2 - My sublime version is 3038

EDIT 2: 1 - I have added the tern command in my tern.sublime-settings files, nothing changed, no errors 2 - I do not have any .tern-project file anywhere. Do I need to add it even for pure js? 3 - Is it possible because I am expecting a similar behaviour as is in the ternjs demo, that the plugin doesn't provide something like this and I misunderstood as a "not working case"?

marijnh commented 8 years ago

Yes, this works with ST3. When things go wrong, I would very much expect error messages in the ctrl-` console. Does it show the plugin to be loaded? Is the file you are editing recognized as being JavaScript?

nkapatos commented 8 years ago

Hello,

From the console when I start sublime in the order show bellow (among other stuff)

Still no errors.

One strange thing I've noticed today and was totally random, is that it decided to add a .tern-port file, in a html/template folder when I saved the file. It happened only once and only in this folder, but when I restarted sublime the file disappeared and a warning in console, said that it was unable to open this file cause it doesn't exist anymore.

marijnh commented 8 years ago

The plugin itself starts tern with --no-port-file. The file you saw was possibly created by you starting the server from the command line.

Does pressing alt-period do anything when you are in a JavaScript file?

nkapatos commented 8 years ago

by pressing atl+. it adds the .tern-port file in the folder where the file is, and usually a message pops that it couldn't find the definition (custom method defined in another file in the same project). If I close the file, the plugin (I'm guessing) deletes the .tern-port file.

marijnh commented 8 years ago

Did you reconfigure the tern_command setting?

marijnh commented 8 years ago

And does jumping to file-local definitions (say, press alt-. on a variable that is defined as a function argument) work?

nkapatos commented 8 years ago

Yes, I have added this line as it was the only thing I haven't done yesterday just in case. "tern_command": ["node", "/Users/nikos/Library/Application Support/Sublime Text 3/Packages/tern_for_sublime/node_modules/tern/bin/tern"]

Testing on a local file it, jumps to variables but not to a function (for example, updateItemsQty: function(item){}). And if I try to call this function it does't give me the arguments but a question mark.

Something that does work today, and no clue why, is that it gives me a tooltip with info for some stuff like the forEach() or the console.log() and the link to mdn with a short description. Still I cannot make it work for document.addEventListener as an autocomplete or to give me info for the method.

marijnh commented 8 years ago

Yes, I have added this line

Ah, that's where the port file comes from (add , "--no-port-file" to the end of the array, or remove the option entirely, to get rid of it)

Still I cannot make it work for document.addEventListener

Are you loading the browser types? ("libs": ["browser"] in .tern-project). By default, you only get built-in types like Date, Object, etc.

nkapatos commented 8 years ago

Ok, I do not know how to explain this, but I was playing around and at some point I tested the plugin like this

function test(a, b, c) {}
test();

var test2 = function(a, b, c) {}
test2();

module.exports =
{
  world: function(a, b, c) {}
  testWorld: function()
  {
    this.world();
  }
}

At the beginning it wouldn't jump to the definition nor show the arguments, but all of a sudden it did!!!! Now it works for everything...

I will add the browser type and test it again. I am sorry that I do not have something not that random to give you information.

marijnh commented 8 years ago

Okay. Feel free to reopen or add a comment if the problem comes back.