tern 0.5 now has experimental angular support built in ternjs.net
Plugin for Tern that enables it to understand AngularJS dependency injection.
- Install tern
- Copy the angular.js file from this repository into your tern_for_sublime plugin directory. For Example:
cp /path/to/angular.js ~/Library/Application Support/Sublime Text 3/Packages/tern_for_sublime/node_modules/tern/plugin
- Create your
.tern-project
file in the base of your project (if you haven't already) and add angular to the plugins. An example .tern-project file with this setup could be:
{
"libs": [
"browser",
"jquery",
"ecma5",
"underscore"
],
"plugins": {
"angular": "./"
}
}
- Make sure if you are using the AngularJS Sublime Text Package that you open User Settings for the package (AngularJS-sublime-package.sublime-settings) and change turn off default JS completions, e.g.:
{ "disable_default_js_completions": true }
- Completions will not work if you use a vanilla JS function.
Will not show completions:
function SomeCtrl($scope, $http) {
$http. // <-- no completions here
}
But this will:
angular.module('MyApp', [])
.controller('SomeCtrl', function($scope, $http) {
$http. // <-- you'll have completions now
});
The completions are worth the effort.