emmetio / sublime-tern

TernJS plugin for Sublime Text
222 stars 15 forks source link

No Completion - No Project Files Found #22

Closed olegbl closed 11 years ago

olegbl commented 11 years ago

Issue: It seems like the "include" setting only narrows the lsit of files scanned by tern, rather than expanding it. I would expect the "include" setting to actually add the directories specified to the list of directories scanned.

Details: I prefer to keep my .sublime-project and .sublime-workspace files in their own, completely unrelated directories, rather than with the source code, in order to keep the repo space cleaner. Consequently, Tern is unable to find any files in my project (since they're in a completely different directory), and is unusable.

Here's my .sublime-project's ternjs section: "ternjs": { "include": ["/Users/username/source/project1/subprojectA/**"], "libs": ["browser", "jquery"], "plugins": { } }

webuniverseio commented 11 years ago

Give a try to loadEagerly setting. Not 100% sure that it will help, but looks worthwhile to check: http://ternjs.net/doc/manual.html#configuration

olegbl commented 11 years ago

Thank you for your reply. Unfortunately, using loadEagerly did not help.

thild42 commented 11 years ago

I had the same problem, and after hours of invetigation, I came to the following statement : you have to place your .sublime-project file in the root directory of your project. For your example : /Users/username/source/project1/ /Users/username/source/project1/project1.sublime-project /Users/username/source/project1/subprojectA/

This constraint is due to the fact that in Sublime-Tern the root directory is retrieved by extracting its name from the absolute path of the .sublime-project file instead of reading the json property "folders->path" from this very same file.

Hope this will help you.

olegbl commented 11 years ago

Thank you for your input! Unfortuantely, I am well aware that placing the .sublime-project into the project directory is what it wants, but I am unable to do that for a variety of organizational reasons.

Basically, the issue is that the plugin is unsuable for me due to this artificial constraint, and I would prefer that there was a way to specify the project path that tern-js would look in.

sergeche commented 11 years ago

I'll try to fix this issue in next few days

olegbl commented 11 years ago

I appreciate that a great deal - thank you!

thild42 commented 11 years ago

oh, great news. I agree with you Oleg when you say that you prefer to keep the .sublime-project and .sublime-workspace outside the sources directory.

sergeche commented 11 years ago

I’ve just pushed update that should solve this issue. You need to define dir preference in ternjs section of your project pointing to your actual project root (include and exclude patters will be resolved against this path).

Note that it will work only in ST3 since ST2 does not has API to get project data so I have to find it in opened file’s path.

PS: I’ve also updated the way how PyV8 (JS engine) works and TernJS core files so there are might be issues with this plugin. Let me know if you have one.

olegbl commented 11 years ago

Awesome, that worked - thank you!

By the way, it seems like TernJS doesn't actually look at the .sublime-project file that's opened, but rather at the first .sublime-project file that's in the same directory as the one that's opened. Luckily, in my case, I can work around that with sub-directories.

ahmedelgabri commented 11 years ago

@sergeche So using ST2 & having project files in a separate location won't make code compilation work?

sergeche commented 11 years ago

@ahmedelgabri it will work in some way if you explicitly open JS files of your project (they will work in context of empty project). ST2 does not provide API for detecting if opened file belongs to project so I have to walk on file’s path to find .sublime-project file.

ghost commented 11 years ago

Currently the plugin is a bit slow when open project at the first time. Does it re-index files for auto completion?

sergeche commented 11 years ago

Yes, it creates initial index of all JS files, included in your project

ghost commented 11 years ago

Can I disable that action? I want to invoke reload function manually instead of auto reloading every time loading my project.

sergeche commented 11 years ago

You can amply exclude all JS files in project settings. Note that in this case code completion will work for edited file only and will not retrieve completion data from other files

ghost commented 11 years ago

Sorry for my bad English. This plugin is helpful for me. But it's pretty annoying when it start TernJS server and re-index files every time I open a project. I have to wait for a while before I can start coding. Can you improve the speed of indexing progress? Thanks.

sergeche commented 11 years ago

Yeah, maybe. I’ll try to implement indexing in separate thread.

sergeche commented 11 years ago

You can also try to limit JS files in index with project settings. It will be especially helpful if you’re writing for Node.js ("exclude": "node_moduels/**") or minify files (exclude folder with minified files)

ahmedelgabri commented 11 years ago

@sergeche I don't know, but even the code completion is not that good with me.

ex. writing doc will get document but when I continue with something like document.get I only get gesturestart I expected to see getElementById, getElementsByTagName, etc...

sergeche commented 11 years ago

Did you added browser lib in your TernJS config?

ahmedelgabri commented 11 years ago

This is my .sublimet-project config not in the same directory as the project itself

{
    "folders":
    [
        {
            "path": "path/to/project"
        }
    ],
    "ternjs": {
        "exclude": ["node_modules/**"],
        "libs": ["browser", "jquery"]
    }
}
sergeche commented 11 years ago

if you are on ST2, it will not work (as described above). You may update default_libs setting to set default libraries for all projects, including empty one: https://github.com/emmetio/sublime-tern/blob/master/TernJS.sublime-settings#L7

ahmedelgabri commented 11 years ago

This worked, Thanks!

zqjimlove commented 8 years ago

i found a bug in controller.js ,fixed is ok!#50