Can't get autocompletion with tern_for_sublime to work

340 views
Skip to first unread message

Simon Vizzini

unread,
Apr 9, 2015, 11:42:51 AM4/9/15
to tern...@googlegroups.com
First off, thank you so much for creating & open sourcing Tern. It looks like the ultimate tool that every JS developer should have!

But I seem to have problems getting Tern to work correctly with Sublime Text. I have the latest Beta (3083) of Sublime Text installed from here: http://www.sublimetext.com/3
This beta version is quite new, maybe that version broke some functionality of the package?

Anyway, my problem is that I can't get autocomplete to work (with ctrl+space). I read the docs for the package and tried to turn on/off all the different options, like "tern_argument_hints" and so on.
All I get by pressing ctrl+space is the default (and useless) Sublime Text autocomplete. I didn't try the "auto_complete_triggers" option yet though, as I'm not really sure what "source.js" is supposed to be. Is this some tern internal file, or just a (random?) JS file from my project?

What seems to work though is when I click on an argument in a function call, then I'll get this popup showing all available arguments (including a link to mozilla developer reference, in case it's a native function).

What also works is "alt+." and "alt+,", but "alt+i" and "alt+q" don't work as they are by default bound to other Sublime functions (I'm still quite new to Sublime and I have yet to look into how to remap those keyboard shortcuts).

On a side note (which may or may not be related to my problem): When I installed tern_for_sublime it told me I don't have tern installed yet and if I'd like to have it downloaded for me. Answering "yes" did nothing for me, I had to go to my "Packages" directory and do "npm install" manually.

Almost forgot: I'm currently running Sublime on Win8.1 x64. I have yet to test tern_for_sublime on my Linux machine.

Marijn Haverbeke

unread,
Apr 10, 2015, 7:04:36 AM4/10/15
to Simon Vizzini, tern-dev
Have you looked whether any error messages appear in the ctrl-` console?
> --
> You received this message because you are subscribed to the Google Groups
> "tern-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to tern-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Simon Vizzini

unread,
Apr 10, 2015, 11:09:07 AM4/10/15
to tern...@googlegroups.com, simon.v...@gmail.com
Sorry, I totally forgot to mention this yesterday. Yesterday there were no errors in the console, but I checked today again and there are indeed some errors, though it seems they are related to the argument hint feature, and not the autocomplete feature? But anyway, argument hinting seems to work fine.

Here's what I have my console:

warning: mnemonic t not found in menu caption Tools
Unable to open clipboard
Traceback (most recent call last):
 
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 296, in on_selection_modified_async
    callback
.on_selection_modified_async(v)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 49, in on_selection_modified_async
    on_selection_modified
(view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 29, in on_selection_modified
   
if pfile is not None: show_argument_hints(pfile, view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 455, in show_argument_hints
    parsed
['url'] = data.get('url', None)
TypeError: 'NoneType' object does not support item assignment
Traceback (most recent call last):
 
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 296, in on_selection_modified_async
    callback
.on_selection_modified_async(v)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 49, in on_selection_modified_async
    on_selection_modified
(view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 29, in on_selection_modified
   
if pfile is not None: show_argument_hints(pfile, view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 455, in show_argument_hints
    parsed
['url'] = data.get('url', None)
TypeError: 'NoneType' object does not support item assignment
Unable to open clipboard
Traceback (most recent call last):
 
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 296, in on_selection_modified_async
    callback
.on_selection_modified_async(v)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 49, in on_selection_modified_async
    on_selection_modified
(view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 29, in on_selection_modified
   
if pfile is not None: show_argument_hints(pfile, view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 455, in show_argument_hints
    parsed
['url'] = data.get('url', None)
AttributeError: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
 
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 296, in on_selection_modified_async
    callback
.on_selection_modified_async(v)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 49, in on_selection_modified_async
    on_selection_modified
(view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 29, in on_selection_modified
   
if pfile is not None: show_argument_hints(pfile, view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 455, in show_argument_hints
    parsed
['url'] = data.get('url', None)
AttributeError: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
 
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 296, in on_selection_modified_async
    callback
.on_selection_modified_async(v)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 49, in on_selection_modified_async
    on_selection_modified
(view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 29, in on_selection_modified
   
if pfile is not None: show_argument_hints(pfile, view)
 
File "C:\Users\vizzini\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 455, in show_argument_hints
    parsed
['url'] = data.get('url', None)
AttributeError: 'NoneType' object has no attribute 'get'

Marijn Haverbeke

unread,
Apr 10, 2015, 11:22:31 AM4/10/15
to Simon Vizzini, tern-dev
Patch [1] should make those go away, but unfortunately the messages do
not make it clear why data was None in the first place -- could be
because the server couldn't be started, or because the current file
isn't recognized as javascript, or because the request failed somehow
(though that should spit out an error message).

[1]: https://github.com/marijnh/tern_for_sublime/commit/ed37d7f670ddf393b0db498d00798237d92d635c

On Fri, Apr 10, 2015 at 5:09 PM, Simon Vizzini

Simon Vizzini

unread,
Apr 10, 2015, 3:08:58 PM4/10/15
to tern...@googlegroups.com, simon.v...@gmail.com
Thanks a bunch, I'll try your patch and do some other tests this weekend
I'll try the previous and current beta versions of Sublime on my Linux & Windows machines and report back my findings. Somehow I have the feeling that the latest Sublime beta might have broken compatibility with tern_for_sublime.

Simon Vizzini

unread,
Apr 12, 2015, 6:35:17 AM4/12/15
to tern...@googlegroups.com, simon.v...@gmail.com
I just tried the sublim_for_tern on Linux (Kubuntu) and here it seems I have a completely different problem, apparently node can't be started ("No such file or directory: 'node').

I guess this will have something to do that I use nvm (node version manager, which allows one to install multiple versions of node/io.js and easily switch between them). nvm will then change the PATH variable according to the chosen node/iojs version, so I can indeed execute the node binary from everywhere.

I'll boot into Windows now and see it works there.

Here's the console output from my Linux:

FileNotFoundError: [Errno 2] No such file or directory: 'node'

Traceback (most recent call last):

 
File "/opt/sublime_text/sublime_plugin.py", line 296, in on_selection_modified_async
    callback
.on_selection_modified_async(v)
 
File "/home/simon/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 49, in on_selection_modified_async
    on_selection_modified
(view)
 
File "/home/simon/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 29, in on_selection_modified
   
if pfile is not None: show_argument_hints(pfile, view)
 
File "/home/simon/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 453, in show_argument_hints
    data
= run_command(view, {"type": "type", "preferFunction": True}, call_start, silent=True)
 
File "/home/simon/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 282, in run_command
    port
, port_is_old = server_port(pfile.project)
 
File "/home/simon/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 154, in server_port
    started
= start_server(project)
 
File "/home/simon/.config/sublime-text-3/Packages/tern_for_sublime/tern.py", line 168, in start_server
    stderr
=subprocess.STDOUT, shell=windows)
 
File "./subprocess.py", line 824, in __init__
 
File "./subprocess.py", line 1448, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'node'

Simon Vizzini

unread,
Apr 12, 2015, 7:56:07 AM4/12/15
to tern...@googlegroups.com, simon.v...@gmail.com
I'm on Windows 8.1 now and I tried it with ST3 build 3065 and 3083, but I can't get autocomplete to work with both versions.

I've also installed the latest version of tern_for_sublime, including the patch you made, but I still get "TypeError: 'NoneType' object does not support item assignment" in the console. I've checked the tern.py in my local packages folder to see if your recent patch is really included, and it is.

Here's the console output:

Traceback (most recent call last):

 
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 295, in on_selection_modified_async
    callback
.on_selection_modified_async(v)
 
File "C:\Users\Simon\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 49, in on_selection_modified_async
    on_selection_modified
(view)
 
File "C:\Users\Simon\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 29, in on_selection_modified
   
if pfile is not None: show_argument_hints(pfile, view)
 
File "C:\Users\Simon\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 456, in show_argument_hints
    parsed
['url'] = data.get('url', None)

TypeError: 'NoneType' object does not support item assignment

Marijn Haverbeke

unread,
Apr 29, 2015, 7:41:39 AM4/29/15
to Simon Vizzini, tern-dev
Hi Simon,

The crash issue you're seeing on windows should be fixed with the
current repository, On Linux, you either don't have node installed,
have it installed under a different name (nodejs?), or it is somehow
now in your PATH variable.

Best,
Marijn

On Sun, Apr 12, 2015 at 1:56 PM, Simon Vizzini
Reply all
Reply to author
Forward
0 new messages