Riko
Riko

Reputation: 572

Is there a way in Sublime Text 2 to support JavaScript completion of objects/functions defined in other files?

If I am editing a .js file in Sublime Text 2 that makes use of a library defined in a separate .js file, is there a way to support tab completion of objects/functions defined in the external library file?

Something analogous to the following from Visual Studio:

/// <reference path="/js/some-library.min.js" />

which enables IntelliSense over the library/plugin code.

Upvotes: 14

Views: 6806

Answers (3)

ericsoco
ericsoco

Reputation: 26253

Another option is TernJS:

http://emmet.io/blog/sublime-tern/

I haven't yet used it, but it looks promising. Editor slowdown seems to be an issue with any code completion plugin; sounds like authors are still working out kinks in scraping and caching related files for code completion. The TernJS page addresses this issue and offers some config options for managing how it handles related files.

Upvotes: 1

robertherber
robertherber

Reputation: 852

I was looking for the exact same thing, and I can confirm that SublimeCodeIntel works well. However, Sublime Text seems slightly less responsive when using SublimeCodeIntel, which is a drawback.

Another cool thing coming from a Visual Studio environment is the support for "Go to definition" in this plugin.

Upvotes: 1

Curtis
Curtis

Reputation: 4031

I haven't tried it myself yet, but there's SublimeCodeIntel: https://github.com/Kronuz/SublimeCodeIntel#readme

The OP in this thread: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=5319 seems to be complaining that it's pulling suggestions from outside the current file, which may mean it's doing what you want.

Upvotes: 4

Related Questions