Code Completion not working
Closed this issue · 18 comments
The plugin installs fine, and the other functions like "Jump to definition" work, but ctrl+space does not do anything, even for the simplest examples.
The only odd thing I noticed was the messages appearing when I restart the ternjs server:
Syncing project /var/www/ld26/ld26.sublime-project
Starting TernJS server for /var/www/ld26/ld26.sublime-project with 2 libs and 2 files
Syncing project empty
Starting TernJS server for empty with 1 libs and 0 files
Here is my sublime-project file:
{
"folders":
[
{
"path": "/var/www/ld26"
}
],
"ternjs": {
"include":["caat.js","game.js"],
"libs": ["browser"]
}
}
There are only 2 js files in the project (caat.js and game.js) both in the root of the project folder.
Do you receive any errors in console? Are other features working?
There are no errors on the console, and all the other features seem to be
working.
Code hinting is working, but not within the context of the variable. For
instance, if I have:
function Thing(){}
doSomething.prototype.doSomething( arg1, arg2 ){}
var foo = new Thing();
When I type "foo." and hit Ctrl+space, nothing happens.
If I type "foo.doSo" then I will get a code hint for "doSomething( arg1,
arg1)", but it will also show all functions that start with "doso".
On Tue, Apr 30, 2013 at 6:55 AM, Sergey Chikuyonok <notifications@github.com
wrote:
Do you receive any errors in console? Are other features working?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-17222805
.
Maybe it’s not important, but code snippet you’ve provided is not valid. This one works fine for me:
function Thing(){}
Thing.prototype.doSomething = function(arg1, arg2) {};
var foo = new Thing();
foo. // completes with doSomething
I have the same issue with the plugin (installs fine, but ctrl+space does nothing). However, with the above example, I do get code completition, if I start typing "do" after the dot. So, something is working, but not the ctrl+space.
Try to explicitly call TernJS: reload
command from Command Palette and check again.
Also, make sure you have the most recent plugin version, I’ve recently updated Tern core.
One more with the same issue. With the above snippet Tern works for me as well, but not in my project.
When I open up my project the console reads (among other things):
TernJS: No need to update PyV8
Syncing project empty
Starting TernJS server for empty with 1 libs and 0 files
(The project is certainly not empty. Even with the modest include
-list, it contains 12 files + several libraries.)
When I open up any source file and start editing the console fills up with:
No sutable server for project "/Library/WebServer/vhosts/sandbox.dev.local/htdocs/module-systems/modules.sublime-project"
My modules.sublime-project
contents:
{
"folders":
[
{
"path": "/Library/WebServer/vhosts/sandbox.dev.local/htdocs/module-systems"
}
],
"ternjs": {
"exclude": [
"node_modules/**",
"server/node_modules/**",
"client-debug/**",
"client-build/**",
"temp/**"
],
"include": [
"server/**",
"client/**"
]
}
}
From your log, I assume that Sublime Tern didn’t loaded your modules.sublime-project
project. Try to call TernJS: Reload
command to refresh TernJS state, it might pick and re-parse your project.
Sorry, I failed to mention I did try "TernJS: Reload", but it simply repeats what it does initially, i.e. nothing.
@nikcorg from your log excerpt, I can see that Emmet starts default server only (for files outside projects). Each project requires separate Tern server instance.
In order to start server, you need to open any .js file of your project and ensure there’s the following message in console:
Syncing project modules.sublime-project
Starting TernJS server for /path/to/modules.sublime-project with X libs and Y files
If you see this message, then server was started correctly.
Another reason why you see no completions might be the Tern itself since it still very buggy. Try to open empty .js file outside project and check completions for basic types like Array
, String
, etc.
Also, you may try the official Tern plugin for ST: https://github.com/marijnh/tern_for_sublime
I’ve just pushed update, it solves some issues with resource management and Tern core evaluation, it might fix completions issues
Same "Project empty" problem here and no code-completion from Librariers or other Files in Folders. Inside a single File (example above) co-co works. I load all the Libs but only get ecma5 so far
"libs": ["ecma5", "browser", "jquery"]
Emmet is installed but disabled. Any Tip how to solve "Project empty"?
The empty
project server works for JS files opened outside Sublime Text projects (that’s why it called empty
, because there’s no project at all).
To add libraries that should be used for all projects (and empty
as well) you can update default_libs
value of your TernJS.sublime-settings
: https://github.com/emmetio/sublime-tern/blob/master/TernJS.sublime-settings
You need to explicitly reload TernJS or restart ST whenever you update this setting.
Thaks for the fast response,
i forgot to mention that the files are already inside a Project (the Project-Config is on a differnet path) but if i open a file from inside the Project i get theempty
message in the console log and only the inline and ecma5 completion.
in the project settings i added
"ternjs": {
"exclude": ["wp-includes/**"],
"libs": ["ecma5", "browser", "jquery"]
}
i was hoping to get jQuery support like this.
After reload it starts the Server for the Project Starting TernJS server for E:\Projects\abc.sublime-project
but still tells me Syncing project empty
Complete Log:
Starting TernJS server for E:\Projects\mondro-tylus.sublime-project with 3 libs and 0 files
Syncing project empty
Starting TernJS server for empty with 1 libs and 0 files
If i add browser
and jquery
to the default_libs in TernJS.sublime-settings
it works for the two, but not for my own js files in the Project...
It will always start server for empty
project.
According to your log, TernJS can’t find any JS files for mondro-tylus.sublime-project
project: the message says it started with 0 files. Make sure your JS files you’re editing are inside E:\Projects
folder and their path doesn’t matches wp-includes/**
pattern.
I have moved my .sublime-project file to project root folder and then it worked. Thanks sergeche for good support.
I hit the same problem as the above users, my system has Debian installed.
theme loaded
app ready
pre session restore time: 0.300237
using gamma: 1 (err: 0)
startup cache, total files: 124 cache hits: 124
startup time: 0.684821 (package setup was not run)
TernJS: No need to update PyV8
Syncing project /home/risto/deekit/app-fe/front.sublime-project
Starting TernJS server for /home/risto/---/replaced-name/front.sublime-project with 2 libs and 495 files
Syncing project empty
Starting TernJS server for empty with 1 libs and 0 files
seems it is a keymap problem, by default in Linux the key shortcut for auto complete (sublime 2.0.2) is "alt+/"
Default (Linux).sublime-keymap:
...
{ "keys": ["alt+/"], "command": "auto_complete" },
{ "keys": ["alt+space"], "command": "replace_completion_with_auto_complete", "context":
[
{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
{ "key": "auto_complete_visible", "operator": "equal", "operand": true },
{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
]
}
...
but it executes no command, you can force the auto complete command execution by running in the application console:
view.run_command("auto_complete")
any idea why?
update
after re installing sublime from zero everything works fine, I'm using this conf:
Default (Linux).sublime-keymap:
[
{ "keys": ["ctrl+space"], "command": "auto_complete" },
{ "keys": ["ctrl+space"], "command": "replace_completion_with_auto_complete", "context":
[
{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
]
}
]
Preferences.sublime-settings:
{
...
"theme": "Spacegray.sublime-theme",
"auto_complete_triggers": [ {"selector": "text.html", "characters": "<"},{"selector": "source.js", "characters": "."} ]
}