├── snippets
├── js2-mode
│ └── .yas-parents
├── web-mode
│ └── .yas-parents
├── js-mode
│ ├── $v.yasnippet
│ ├── $va.yasnippet
│ ├── $e.yasnippet
│ ├── $b.yasnippet
│ ├── ngm.yasnippet
│ ├── $f.yasnippet
│ ├── ngs.yasnippet
│ ├── ngfa.yasnippet
│ ├── ngro.yasnippet
│ ├── $on.yasnippet
│ ├── ngc.yasnippet
│ ├── $w.yasnippet
│ ├── ngw.yasnippet
│ ├── ngrw.yasnippet
│ ├── ngfi.yasnippet
│ ├── ngd.yasnippet
│ └── ngrwr.yasnippet
└── html-mode
│ ├── ng-csp.yasnippet
│ ├── ng-form.yasnippet
│ ├── ng-list.yasnippet
│ ├── ng-src.yasnippet
│ ├── ng-view.yasnippet
│ ├── ng-bind.yasnippet
│ ├── ng-cloak.yasnippet
│ ├── ng-hide.yasnippet
│ ├── ng-href.yasnippet
│ ├── ng-init.yasnippet
│ ├── ng-show.yasnippet
│ ├── ng-click.yasnippet
│ ├── ng-model.yasnippet
│ ├── ng-style.yasnippet
│ ├── ng-change.yasnippet
│ ├── ng-readonly.yasnippet
│ ├── ng-submit.yasnippet
│ ├── ng-switch.yasnippet
│ ├── ng-app.yasnippet
│ ├── ng-checked.yasnippet
│ ├── ng-dblclick.yasnippet
│ ├── ng-disabled.yasnippet
│ ├── ng-include.yasnippet
│ ├── ng-mouseup.yasnippet
│ ├── ng-multiple.yasnippet
│ ├── ng-selected.yasnippet
│ ├── ng-class-odd.yasnippet
│ ├── ng-mousedown.yasnippet
│ ├── ng-mousemove.yasnippet
│ ├── ng-mouseover.yasnippet
│ ├── ng-transclude.yasnippet
│ ├── ng-class-even.yasnippet
│ ├── ng-controller.yasnippet
│ ├── ng-mouseenter.yasnippet
│ ├── ng-mouseleave.yasnippet
│ ├── ng-repeat.yasnippet
│ ├── ng-bind-template.yasnippet
│ ├── ng-class.yasnippet
│ ├── ng-non-bindable.yasnippet
│ ├── ng-bind-html-unsafe.yasnippet
│ ├── ng-options.yasnippet
│ └── ng-pluralize.yasnippet
├── Carton
├── angular-snippets-pkg.el
├── README.md
└── angular-snippets.el
/snippets/js2-mode/.yas-parents:
--------------------------------------------------------------------------------
1 | js-mode
2 |
--------------------------------------------------------------------------------
/snippets/web-mode/.yas-parents:
--------------------------------------------------------------------------------
1 | html-mode
2 |
--------------------------------------------------------------------------------
/Carton:
--------------------------------------------------------------------------------
1 | (source "melpa" "http://melpa.milkbox.net/packages/")
2 |
3 | (package-file "angular-snippets.el")
4 |
--------------------------------------------------------------------------------
/snippets/js-mode/$v.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: $v
3 | # key: $v
4 | # --
5 | $scope.$1 = $2;
6 | $0
--------------------------------------------------------------------------------
/snippets/js-mode/$va.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: $va
3 | # key: $va
4 | # --
5 | $scope.$1 = $1;
6 | $0
--------------------------------------------------------------------------------
/snippets/js-mode/$e.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: $e
3 | # key: $e
4 | # --
5 | $scope.$emit("$1", $2);
6 | $0
--------------------------------------------------------------------------------
/snippets/js-mode/$b.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: $b
3 | # key: $b
4 | # --
5 | $scope.$broadcast("$1", $2);
6 | $0
--------------------------------------------------------------------------------
/snippets/js-mode/ngm.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngm
3 | # key: ngm
4 | # --
5 | angular.module("$1", [$2]);
6 |
--------------------------------------------------------------------------------
/angular-snippets-pkg.el:
--------------------------------------------------------------------------------
1 | (define-package "angular-snippets" "0.2.3"
2 | "Yasnippets for AngularJS"
3 | '((s "1.4.0") (dash "1.2.0")))
4 |
--------------------------------------------------------------------------------
/snippets/js-mode/$f.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: $f
3 | # key: $f
4 | # --
5 | $scope.$1 = function ($2) {
6 | $0
7 | };
8 |
--------------------------------------------------------------------------------
/snippets/js-mode/ngs.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngs
3 | # key: ngs
4 | # --
5 | service("$1", function () {
6 | $3
7 | });
8 |
--------------------------------------------------------------------------------
/snippets/js-mode/ngfa.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngfa
3 | # key: ngfa
4 | # --
5 | factory("$1", function ($2) {
6 | $3
7 | })
8 |
--------------------------------------------------------------------------------
/snippets/js-mode/ngro.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngro
3 | # key: ngro
4 | # --
5 | $routeProvider.otherwise({redirectTo: "$1"});
6 | $0
--------------------------------------------------------------------------------
/snippets/js-mode/$on.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: $on
3 | # key: $on
4 | # --
5 | $scope.$on("$1", function (event, $2) {
6 | $0
7 | });
--------------------------------------------------------------------------------
/snippets/js-mode/ngc.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngc
3 | # key: ngc
4 | # --
5 | controller('$1', function ($scope, $2) {
6 | $0
7 | });
--------------------------------------------------------------------------------
/snippets/js-mode/$w.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: $w
3 | # key: $w
4 | # --
5 | $scope.$watch("$1", function (newValue, oldValue) {
6 | $0
7 | });
--------------------------------------------------------------------------------
/snippets/js-mode/ngw.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngw
3 | # key: ngw
4 | # --
5 | when("/$1", {
6 | templateUrl: "$2",
7 | controller: "$0"
8 | })
--------------------------------------------------------------------------------
/snippets/html-mode/ng-csp.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-csp
3 | # key: ng
4 | # --
5 | ng-csp`
6 | (ng-snip/docs "ng-csp")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-form.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-form
3 | # key: ng
4 | # --
5 | ng-form`
6 | (ng-snip/docs "ng-form")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-list.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-list
3 | # key: ng
4 | # --
5 | ng-list`
6 | (ng-snip/docs "ng-list")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-src.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-src
3 | # key: ng
4 | # --
5 | ng-src="$0"`
6 | (ng-snip/docs "ng-src")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-view.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-view
3 | # key: ng
4 | # --
5 | ng-view`
6 | (ng-snip/docs "ng-view")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-bind.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-bind
3 | # key: ng
4 | # --
5 | ng-bind="$0"`
6 | (ng-snip/docs "ng-bind")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-cloak.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-cloak
3 | # key: ng
4 | # --
5 | ng-cloak`
6 | (ng-snip/docs "ng-cloak")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-hide.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-hide
3 | # key: ng
4 | # --
5 | ng-hide="$0"`
6 | (ng-snip/docs "ng-hide")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-href.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-href
3 | # key: ng
4 | # --
5 | ng-href="$0"`
6 | (ng-snip/docs "ng-href")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-init.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-init
3 | # key: ng
4 | # --
5 | ng-init="$0"`
6 | (ng-snip/docs "ng-init")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-show.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-show
3 | # key: ng
4 | # --
5 | ng-show="$0"`
6 | (ng-snip/docs "ng-show")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-click.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-click
3 | # key: ng
4 | # --
5 | ng-click="$0"`
6 | (ng-snip/docs "ng-click")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-model.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-model
3 | # key: ng
4 | # --
5 | ng-model="$0"`
6 | (ng-snip/docs "ng-model")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-style.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-style
3 | # key: ng
4 | # --
5 | ng-style="$0"`
6 | (ng-snip/docs "ng-style")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/js-mode/ngrw.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngrw
3 | # key: ngrw
4 | # --
5 | $routeProvider.when("$1", {
6 | templateUrl: "$2",
7 | controller: "$3"
8 | });
9 | $0
--------------------------------------------------------------------------------
/snippets/html-mode/ng-change.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-change
3 | # key: ng
4 | # --
5 | ng-change="$0"`
6 | (ng-snip/docs "ng-change")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-readonly.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-readonly
3 | # key: ng
4 | # --
5 | ng-readonly`
6 | (ng-snip/docs "ng-readonly")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-submit.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-submit
3 | # key: ng
4 | # --
5 | ng-submit="$0"`
6 | (ng-snip/docs "ng-submit")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-switch.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-switch
3 | # key: ng
4 | # --
5 | ng-switch="$0"`
6 | (ng-snip/docs "ng-switch")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-app.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-app
3 | # key: ng
4 | # --
5 | ng-app${1:="${2:module}"}$0`
6 | (ng-snip/docs "ng-app")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-checked.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-checked
3 | # key: ng
4 | # --
5 | ng-checked="$0"`
6 | (ng-snip/docs "ng-checked")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-dblclick.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-dblclick
3 | # key: ng
4 | # --
5 | ng-dblclick="$0"`
6 | (ng-snip/docs "ng-dblclick")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-disabled.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-disabled
3 | # key: ng
4 | # --
5 | ng-disabled="$0"`
6 | (ng-snip/docs "ng-disabled")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-include.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-include
3 | # key: ng
4 | # --
5 | ng-include="'$0'"`
6 | (ng-snip/docs "ng-include")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-mouseup.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-mouseup
3 | # key: ng
4 | # --
5 | ng-mouseup="$0"`
6 | (ng-snip/docs "ng-mouseup")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-multiple.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-multiple
3 | # key: ng
4 | # --
5 | ng-multiple="$0"`
6 | (ng-snip/docs "ng-multiple")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-selected.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-selected
3 | # key: ng
4 | # --
5 | ng-selected="$0"`
6 | (ng-snip/docs "ng-selected")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-class-odd.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-class-odd
3 | # key: ng
4 | # --
5 | ng-class-odd="$0"`
6 | (ng-snip/docs "ng-class-odd")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-mousedown.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-mousedown
3 | # key: ng
4 | # --
5 | ng-mousedown="$0"`
6 | (ng-snip/docs "ng-mousedown")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-mousemove.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-mousemove
3 | # key: ng
4 | # --
5 | ng-mousemove="$0"`
6 | (ng-snip/docs "ng-mousemove")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-mouseover.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-mouseover
3 | # key: ng
4 | # --
5 | ng-mouseover="$0"`
6 | (ng-snip/docs "ng-mouseover")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-transclude.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-transclude
3 | # key: ng
4 | # --
5 | ng-transclude`
6 | (ng-snip/docs "ng-transclude")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/js-mode/ngfi.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngfi
3 | # key: ngfi
4 | # --
5 | filter("$1", function ($2) {
6 | return function (input, $3) {
7 | $3
8 | };
9 | });
10 |
--------------------------------------------------------------------------------
/snippets/html-mode/ng-class-even.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-class-even
3 | # key: ng
4 | # --
5 | ng-class-even="$0"`
6 | (ng-snip/docs "ng-class-even")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-controller.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-controller
3 | # key: ng
4 | # --
5 | ng-controller="$0"`
6 | (ng-snip/docs "ng-controller")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-mouseenter.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-mouseenter
3 | # key: ng
4 | # --
5 | ng-mouseenter="$0"`
6 | (ng-snip/docs "ng-mouseenter")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-mouseleave.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-mouseleave
3 | # key: ng
4 | # --
5 | ng-mouseleave="$0"`
6 | (ng-snip/docs "ng-mouseleave")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-repeat.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-repeat
3 | # key: ng
4 | # --
5 | ng-repeat="${1:thing} in ${2:$1s}"`
6 | (ng-snip/docs "ng-repeat")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-bind-template.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-bind-template
3 | # key: ng
4 | # --
5 | ng-bind-template="$0"`
6 | (ng-snip/docs "ng-bind-template")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-class.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-class
3 | # key: ng
4 | # --
5 | ng-class="{'${1:class}': ${2:condition}$0}"`
6 | (ng-snip/docs "ng-class")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-non-bindable.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-non-bindable
3 | # key: ng
4 | # --
5 | ng-non-bindable="$0"`
6 | (ng-snip/docs "ng-non-bindable")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/js-mode/ngd.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngd
3 | # key: ngd
4 | # --
5 | directive('$1', function ($2) {
6 | return function (scope, element, attrs$4) {
7 | $3
8 | };
9 | });
10 |
--------------------------------------------------------------------------------
/snippets/js-mode/ngrwr.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ngrwr
3 | # key: ngrwr
4 | # --
5 | $routeProvider.when("$1", {
6 | templateUrl: "$2",
7 | controller: "$3",
8 | resolve: {$0
9 | }
10 | });
11 |
--------------------------------------------------------------------------------
/snippets/html-mode/ng-bind-html-unsafe.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-bind-html-unsafe
3 | # key: ng
4 | # --
5 | ng-bind-html-unsafe="$0"`
6 | (ng-snip/docs "ng-bind-html-unsafe")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-options.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-options
3 | # key: ng
4 | # --
5 | ng-options="${1:${2:item}.${3:value} as $2.${4:label} for $2 in ${5:$2s}}"`
6 | (ng-snip/docs "ng-options")
7 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/snippets/html-mode/ng-pluralize.yasnippet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: ng-pluralize
3 | # key: ng
4 | # --
5 | ng-pluralize count="${1:model}" when="{
6 | '0': '${2:none}',
7 | 'one': '${3:one}',
8 | 'other': '{} $0'
9 | }"`
10 | (ng-snip/docs "ng-pluralize")
11 | (ng-snip/maybe-space-after-attr)`
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # angular-snippets.el
2 |
3 | Yasnippets for [AngularJS](http://angularjs.org/).
4 |
5 | ## Installation
6 |
7 | I highly recommend installing angular-snippets through elpa.
8 |
9 | It's available on [marmalade](http://marmalade-repo.org/) and
10 | [melpa](http://melpa.milkbox.net/):
11 |
12 | M-x package-install angular-snippets
13 |
14 | You can also install the dependencies on your own, and just dump
15 | angular-snippets in your path somewhere:
16 |
17 | - s.el
18 | - dash.el
19 |
20 | ## Usage
21 |
22 | Right now there's only snippets for `html-mode` (mirrored into
23 | `web-mode`) for the `ng-*` attribute directives. They all expand from `ng`.
24 |
25 | Something slightly cool is that you get a short message with docs when
26 | you expand a directive. You can also use `ng-snip-show-docs-at-point`
27 | to show documentation for the closest `ng-*` directive. I have it on
28 | `C-c C-d`. Pressing it again within 10 seconds opens the relevant
29 | documentation in your browser.
30 |
31 | ## Setup
32 |
33 | Well, you'll have to require it. You'll also need
34 | [yasnippets](https://github.com/capitaomorte/yasnippet) of course
35 | (sorry about the insult if that wasn't obvious, but dude, you had it
36 | coming).
37 |
38 | (require 'angular-snippets)
39 |
40 | I would also recommend adding `ng-snip-show-docs-at-point` to get that
41 | nice documentation lookup thingie. Maybe something along the lines of:
42 |
43 | (eval-after-load "sgml-mode"
44 | '(define-key html-mode-map (kbd "C-c C-d") 'ng-snip-show-docs-at-point))
45 |
46 | ## Todo
47 |
48 | The sky is the limit. There is lots room in AngularJS for awesome tooling
49 | support, but this package isn't that. Not yet, at least. I'm adding to
50 | it as I go along. Join me if you want.
51 |
52 | ## License
53 |
54 | Copyright (C) 2013 Magnar Sveen
55 |
56 | This program is free software; you can redistribute it and/or modify
57 | it under the terms of the GNU General Public License as published by
58 | the Free Software Foundation, either version 3 of the License, or
59 | (at your option) any later version.
60 |
61 | This program is distributed in the hope that it will be useful,
62 | but WITHOUT ANY WARRANTY; without even the implied warranty of
63 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64 | GNU General Public License for more details.
65 |
66 | You should have received a copy of the GNU General Public License
67 | along with this program. If not, see .
68 |
--------------------------------------------------------------------------------
/angular-snippets.el:
--------------------------------------------------------------------------------
1 | ;;; angular-snippets.el --- Yasnippets for AngularJS
2 |
3 | ;; Copyright (C) 2013 Magnar Sveen
4 |
5 | ;; Author: Magnar Sveen
6 | ;; Keywords: snippets
7 | ;; Version: 0.2.3
8 | ;; Package-Requires: ((s "1.4.0") (dash "1.2.0"))
9 |
10 | ;; This program is free software; you can redistribute it and/or modify
11 | ;; it under the terms of the GNU General Public License as published by
12 | ;; the Free Software Foundation, either version 3 of the License, or
13 | ;; (at your option) any later version.
14 |
15 | ;; This program is distributed in the hope that it will be useful,
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | ;; GNU General Public License for more details.
19 |
20 | ;; You should have received a copy of the GNU General Public License
21 | ;; along with this program. If not, see .
22 |
23 | ;;; Commentary:
24 |
25 | ;; Yasnippets for [AngularJS](http://angularjs.org/).
26 |
27 | ;;; Code:
28 |
29 | (require 'yasnippet)
30 | (require 'dash)
31 | (require 's)
32 |
33 | ;;;###autoload
34 | (defun ng-snip-show-docs-at-point ()
35 | (interactive)
36 | (ng-snip/show-or-browse-docs (ng-snip/closest-ng-identifer)))
37 |
38 | (defvar ng-directive-docstrings
39 | '(("ng-app" . "Auto-bootstraps an application, with optional module to load.")
40 | ("ng-bind" . "Replace text content of element with value of given expression.")
41 | ("ng-bind-html-unsafe" . "Set innerHTML of element to unsanitized value of given expression.")
42 | ("ng-bind-template" . "Replace text content of element with given template.")
43 | ("ng-change" . "Eval the given expression when user changes the input. Requires ng-model.")
44 | ("ng-checked" . "Uses given expression to determine checked-state of checkbox.")
45 | ("ng-class" . "Sets class names on element based on given expression.")
46 | ("ng-class-even" . "Like ng-class, but only on even rows. Requires ng-repeat.")
47 | ("ng-class-odd" . "Like ng-class, but only on odd rows. Requires ng-repeat.")
48 | ("ng-click" . "Eval the given expression when element is clicked.")
49 | ("ng-cloak" . "Hides the element contents until compiled by angular.")
50 | ("ng-controller" . "Assign controller to this element, along with a new scope.")
51 | ("ng-csp" . "Enables Content Security Policy support. Should be on same element as ng-app.")
52 | ("ng-dblclick" . "Eval the given expression when element is double clicked.")
53 | ("ng-disabled" . "Uses given expression to determine disabled-state of element.")
54 | ("ng-form" . "Nestable alias of the form directive.")
55 | ("ng-hide" . "Hides the element if the expression is truthy.")
56 | ("ng-href" . "Avoids bad URLs on links that are clicked before angular compiles them.")
57 | ("ng-include" . "Fetches, compiles and includes an external HTML fragment.")
58 | ("ng-init" . "Evals expression before executing template during bootstrap.")
59 | ("ng-list" . "Text input that converts between comma-separated string and an array of strings.")
60 | ("ng-model" . "Sets up two-way data binding. Works with input, select and textarea.")
61 | ("ng-mousedown" . "Eval the given expression on mousedown.")
62 | ("ng-mouseenter" . "Eval the given expression on mouseenter.")
63 | ("ng-mouseleave" . "Eval the given expression on mouseleave.")
64 | ("ng-mousemove" . "Eval the given expression on mousemove.")
65 | ("ng-mouseover" . "Eval the given expression on mouseover.")
66 | ("ng-mouseup" . "Eval the given expression on mouseup.")
67 | ("ng-multiple" . "Uses given expression to determine multiple-state of select element.")
68 | ("ng-non-bindable" . "Makes angular ignore {{bindings}} inside element.")
69 | ("ng-options" . "Populates select options from a list or object.")
70 | ("ng-pluralize" . "Helps change wording based on a number.")
71 | ("ng-readonly" . "Uses given expression to determine readonly-state of element.")
72 | ("ng-repeat" . "Repeats template for every item in a list.")
73 | ("ng-selected" . "Uses given expression to determine selected-state of option element.")
74 | ("ng-show" . "Hides the element if the expression is falsy.")
75 | ("ng-src" . "Stops browser from fetching images with {{templates}} in the URL.")
76 | ("ng-style" . "Sets style attributes from an object of DOM style properties. ")
77 | ("ng-submit" . "Eval the given expression when form is submitted, and prevent default.")
78 | ("ng-switch" . "Switch on given expression to conditionally change DOM structure.")
79 | ("ng-switch-when" . "Include this element if value matches ng-switch on expression.")
80 | ("ng-transclude" . "Signifies where to insert transcluded DOM.")
81 | ("ng-view" . "Signifies where route views are shown.")))
82 |
83 | (defvar ng-snip/docs-indirection
84 | '(("ng-options" . "select")
85 | ("ng-switch-when" . "ng-switch")))
86 |
87 | (defvar ng-snip/directive-root-url
88 | "http://docs.angularjs.org/api/ng.directive:")
89 |
90 | (defun -aget (alist key)
91 | (cdr (assoc key alist)))
92 |
93 | (defun ng-snip/directive-to-docs (directive)
94 | (let ((name (car directive))
95 | (docstring (cdr directive)))
96 | (list name
97 | :docstring docstring
98 | :docurl (s-with (or (-aget ng-snip/docs-indirection name) name)
99 | (s-lower-camel-case)
100 | (concat ng-snip/directive-root-url)))))
101 |
102 | (setq ng-docs (-map 'ng-snip/directive-to-docs ng-directive-docstrings))
103 |
104 | (defun ng-snip/docs-value (id prop)
105 | (plist-get (-aget ng-docs id) prop))
106 |
107 | (defvar ng-snip/last-docs-message nil)
108 |
109 | (defun ng-snip/forget-last-docs-message ()
110 | (setq ng-snip/last-docs-message nil))
111 |
112 | (defun ng-snip/docs (id)
113 | (message (ng-snip/docs-value id :docstring))
114 | (setq ng-snip/last-docs-message id)
115 | (run-with-timer 10.0 nil 'ng-snip/forget-last-docs-message)
116 | nil)
117 |
118 | (defun ng-snip/show-or-browse-docs (id)
119 | (if (s-equals? ng-snip/last-docs-message id)
120 | (ng-snip/browse-docs id)
121 | (ng-snip/docs id)))
122 |
123 | (defun ng-snip/browse-docs (id)
124 | (browse-url (ng-snip/docs-value id :docurl)))
125 |
126 | (defun ng-snip/maybe-space-after-attr ()
127 | (unless (looking-at "[ />]\\|$")
128 | (insert " ")))
129 |
130 | (defun ng-snip/closest-ng-identifer ()
131 | (save-excursion
132 | (forward-char 3)
133 | (search-backward "ng-")
134 | (unless (looking-at "ng-[a-z\-]+")
135 | (error "No angular identifier at point"))
136 | (match-string 0)))
137 |
138 | (setq angular-snippets-root (file-name-directory (or load-file-name
139 | (buffer-file-name))))
140 |
141 | ;;;###autoload
142 | (defun angular-snippets-initialize ()
143 | (let ((snip-dir (expand-file-name "snippets" angular-snippets-root)))
144 | (when (boundp 'yas-snippet-dirs)
145 | (add-to-list 'yas-snippet-dirs snip-dir t))
146 | (yas-load-directory snip-dir)))
147 |
148 | ;;;###autoload
149 | (eval-after-load "yasnippet"
150 | '(angular-snippets-initialize))
151 |
152 | (provide 'angular-snippets)
153 | ;;; angular-snippets.el ends here
154 |
--------------------------------------------------------------------------------