cajus / AngularJS-tern-plugin

A, slow'ish moving, WIP plugin for Tern that enables it to understand AngularJS dependency injection.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AngularJS-tern-plugin

tern 0.5 now has experimental angular support built in ternjs.net

Plugin for Tern that enables it to understand AngularJS dependency injection.

View Example

Installation

  1. Install tern
  2. 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
  1. 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": "./"
    }
  }
  1. 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 }
  1. 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.

About

A, slow'ish moving, WIP plugin for Tern that enables it to understand AngularJS dependency injection.