Code Monkey home page Code Monkey logo

angularjs-tern-plugin's Introduction

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.

angularjs-tern-plugin's People

Contributors

bfricka avatar subhaze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

angularjs-tern-plugin's Issues

Conflicting w/ AngularJS Sublime Package

This is such a spectacular implementation. I'm opening this b/c it's been 2 months w/ an update and I wanted to inquire as to what direction this plugin is going, and offer any help.

One of the main issues I found was that this will not provide completions when used in conjunction w/ the AngularJS Sublime Package. For me, that's fine, b/c I already know the API, and I'd rather have type help than API help. Thus, I just don't use the Sublime Package. However, the Sublime Package is an important part of the AngularJS community and angular-ui project, and so they really should work together if desired.

Another gripe, was getting setup, which is a Tern issue (or a me issue). I'd be happy to contribute the README for this. Hopefully adding plugins to Tern becomes easier to manage in the future.

Finally, it's been a couple weeks since I looked at the source for this, but I'm wondering if the full API is implemented here? Specifically, I'm wondering if the 1.1.x branch API is supported. A quick glance says no. If not, would you be open to creating a branch for that, so we can get support out for animate, etc. This will make it easier to update for the upcoming 1.2 release as well.

I know that's a lot, but I love AngularJS and Tern, and this is a solid initial implementation, so I'm offering help and soliciting discussion for the future.

IDE Team

@subhaze you should have ownership of this repo back. Sorry I just noticed the transfer now.

No support for Angular mocks injection

Angular mocks supports prefixing/suffixing with underscores as a convenience for injecting in values during tests.

var $q, $rootScope, myService;
beforeEach(inject(function(_$q_, _$rootScope, _myService_) {
  $q = _$q_;
  $rootScope = _$rootScope_;
  myService = _myService_;
}));

It'd be great if tern recognized these. As it stands, completion engines completely fail when this syntax is used.

Help needed to set the plugin to be used in vim

Hi!

I know the plugin is mainly intended to be used with Sublime Text, but it seems it can also be used with vim. The problem is that I couldn't make it works. I would really appreciate if someone could show me what I'm doing wrong.

The steps I followed:

  • I have Tern and Tern for Vim installed and working;
  • I've put angular.js in ~/.vim/bundle/tern_for_vim/node_modules_tern (the directory that contains node.js, doc_comment.js and requirejs.js);
  • I've created a .tern-project file in the root of my project containing:
{
  "libs": [
    "browser",
    "ecma5"
  ],
  "plugins": {
    "angular": "./"
  }
}

Is it right? Is it enough information?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.