├── snippets ├── js2-mode │ └── .yas-parents ├── rjsx-mode │ └── .yas-parents ├── web-mode │ └── .yas-parents └── js-mode │ ├── export.yasnippet │ ├── map.yasnippet │ ├── set.yasnippet │ ├── spread.yasnippet │ ├── super.yasnippet │ ├── let.yasnippet │ ├── proxy.yasnippet │ ├── symbol.yasnippet │ ├── import.yasnippet │ ├── template-string.yasnippet │ ├── weak-map.yasnippet │ ├── weak-set.yasnippet │ ├── class.yasnippet │ ├── constant.yasnippet │ ├── string-interpolate.yasnippet │ ├── arrow.yasnippet │ ├── export-default.yasnippet │ ├── for-of.yasnippet │ ├── promise.yasnippet │ ├── constructor.yasnippet │ ├── class-extends.yasnippet │ └── export-function.yasnippet ├── es6-snippets.el └── README.org /snippets/js2-mode/.yas-parents: -------------------------------------------------------------------------------- 1 | js-mode -------------------------------------------------------------------------------- /snippets/rjsx-mode/.yas-parents: -------------------------------------------------------------------------------- 1 | js-mode -------------------------------------------------------------------------------- /snippets/web-mode/.yas-parents: -------------------------------------------------------------------------------- 1 | js-mode -------------------------------------------------------------------------------- /snippets/js-mode/export.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#export 3 | # key: exp 4 | # -- 5 | export $0; -------------------------------------------------------------------------------- /snippets/js-mode/map.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#map 3 | # key: map 4 | # -- 5 | new Map($0); -------------------------------------------------------------------------------- /snippets/js-mode/set.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#set 3 | # key: set 4 | # -- 5 | new Set($0); -------------------------------------------------------------------------------- /snippets/js-mode/spread.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#spread 3 | # key: spr 4 | # -- 5 | (...$1)$0 -------------------------------------------------------------------------------- /snippets/js-mode/super.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#super 3 | # key: sup 4 | # -- 5 | super($0); -------------------------------------------------------------------------------- /snippets/js-mode/let.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#letVariable 3 | # key: let 4 | # -- 5 | let $1 = $0; -------------------------------------------------------------------------------- /snippets/js-mode/proxy.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#proxy 3 | # key: px 4 | # -- 5 | new Proxy($1, $0); -------------------------------------------------------------------------------- /snippets/js-mode/symbol.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#symbol 3 | # key: sym 4 | # -- 5 | Symbol($0); -------------------------------------------------------------------------------- /snippets/js-mode/import.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#import 3 | # key: imp 4 | # -- 5 | import $1 from $0; -------------------------------------------------------------------------------- /snippets/js-mode/template-string.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#templateString 3 | # key: ts 4 | # -- 5 | `$0` -------------------------------------------------------------------------------- /snippets/js-mode/weak-map.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#weakMap 3 | # key: wmap 4 | # -- 5 | new WeakMap($0); -------------------------------------------------------------------------------- /snippets/js-mode/weak-set.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#weakSet 3 | # key: wset 4 | # -- 5 | new WeakSet($0); -------------------------------------------------------------------------------- /snippets/js-mode/class.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#class 3 | # key: cl 4 | # -- 5 | class $1 { 6 | $0 7 | } 8 | -------------------------------------------------------------------------------- /snippets/js-mode/constant.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#constVariable 3 | # key: const 4 | # -- 5 | const $1 = $0; -------------------------------------------------------------------------------- /snippets/js-mode/string-interpolate.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#stringInterpolation 3 | # key: si 4 | # -- 5 | ${$0} -------------------------------------------------------------------------------- /snippets/js-mode/arrow.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#arrowFunction 3 | # key: arw 4 | # -- 5 | ($1) => { 6 | $0 7 | } 8 | -------------------------------------------------------------------------------- /snippets/js-mode/export-default.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#exportDefault 3 | # key: expd 4 | # -- 5 | export default $0; 6 | -------------------------------------------------------------------------------- /snippets/js-mode/for-of.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#forOfLoop 3 | # key: forof 4 | # -- 5 | for($1 of $2) { 6 | $0 7 | } -------------------------------------------------------------------------------- /snippets/js-mode/promise.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#promise 3 | # key: prom 4 | # -- 5 | new Promise(($1) => { 6 | $0 7 | }); -------------------------------------------------------------------------------- /snippets/js-mode/constructor.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#constructor 3 | # key: ccs 4 | # -- 5 | constructor($1) { 6 | $0 7 | } 8 | -------------------------------------------------------------------------------- /snippets/js-mode/class-extends.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#classExtends 3 | # key: cle 4 | # -- 5 | class $1 extends $2 { 6 | $0 7 | } -------------------------------------------------------------------------------- /snippets/js-mode/export-function.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: es6#exportFunction 3 | # key: expf 4 | # -- 5 | export function $1($2) { 6 | $0 7 | } -------------------------------------------------------------------------------- /es6-snippets.el: -------------------------------------------------------------------------------- 1 | ;;; es6-snippets.el --- Yasnippets for ECMAScript 6 2 | ;; 3 | ;; Copyright (C) 2015 Cody Reichert 4 | ;; 5 | ;; Author: Cody Reichert 6 | ;; URL: http://github.com/CodyReichert/es6-snippets 7 | ;; Keywords: convenience snippets javascript es6 8 | ;; Version: 0.0.1 9 | ;; Package-Requires: ((yasnippet "0.7.0")) 10 | ;; 11 | ;; This program is free software; you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | ;; 16 | ;; This program is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | ;; 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with this program. If not, see . 23 | ;; 24 | ;;; Commentary: 25 | ;; 26 | ;; es6-snippets provides Yasnippets for ECMAScript 6 features and syntax. 27 | ;; 28 | ;;; Code: 29 | 30 | (defvar es6-snippets-root (file-name-directory (or load-file-name 31 | (buffer-file-name)))) 32 | 33 | ;;;###autoload 34 | (defun es6-snippets-initialize () 35 | "Load es6-snippets." 36 | (let ((snippets-dir (expand-file-name "snippets" es6-snippets-root))) 37 | (when (boundp 'yas-snippet-dirs) 38 | (add-to-list 'yas-snippet-dirs snippets-dir t)) 39 | (yas-load-directory snippets-dir))) 40 | 41 | ;;;###autoload 42 | (eval-after-load 'yasnippet 43 | '(es6-snippets-initialize)) 44 | 45 | (require 'yasnippet) 46 | 47 | (provide 'es6-snippets) 48 | ;;; es6-snippets.el ends here 49 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+TITLE: es6-snippets.el 2 | #+AUTHOR: Cody Reichert 3 | #+EMAIL: codyreichert@gmail.com 4 | #+DESCRIPTION: A collection of Yasnippets for writing EcmaScript 2016 in GNU Emacs 5 | #+LANGUAGE: en 6 | 7 | *es6-snippets.el* is a collection of [[https://github.com/capitaomorte/yasnippet][Yanippets]] for writing EcmaScript 8 | 2015 in Emacs. 9 | 10 | This is almost comprehensive, but snippets are still being changed and 11 | added. 12 | 13 | See the [[https://people.mozilla.org/~jorendorff/es6-draft.html][ES6 Standard draft]] for a full spec. 14 | 15 | 16 | ** Installation 17 | First get the source: 18 | 19 | #+BEGIN_SRC sh 20 | $ git clone git@github.com:codyreichert/es6-snippets ~/.emacs.d/es6-snippets 21 | #+END_SRC 22 | 23 | Then require the package: 24 | 25 | #+BEGIN_SRC emacs-lisp 26 | (add-to-list 'load-path "~/.emacs.d/es6-snippets") 27 | (require 'es6-snippets) 28 | #+END_SRC 29 | 30 | /There's plenty of other ways, so do what works best for you/ 31 | 32 | 33 | ** Prerequisites 34 | Yasnippets needs to be enabled, but once once it is and you've 35 | required the package in your init.el, snippets will be available in 36 | =web-mode=, =js2-mode=, or =js-mode=. 37 | 38 | 39 | ** Snippets 40 | 41 | | Snippet | Name | Description | 42 | |---------+-------------------+---------------------------------| 43 | | arw | arrowFunction | =($1) => { $0 }= | 44 | | cl | class | =class $1 { $0 }= | 45 | | cle | classExtends | =class $1 extends $2 { $0 }= | 46 | | ccs | classConstructor | =constructor($1) { $0 }= | 47 | | const | constant | =const $1 = $0;= | 48 | | exp | export | =export $0;= | 49 | | expd | exportDefault | =export default $0;= | 50 | | expf | exportFunction | =export function $1($2) { $0 }= | 51 | | forof | forOfLoop | =for($1 of $2) { $0 }= | 52 | | imp | import | =import $0;= | 53 | | let | let | =let $1 = $0;= | 54 | | map | map | =new Map($0);= | 55 | | prom | promise | =new Promise(($1) => { $0 });= | 56 | | px | proxy | =new Proxy($1, $0);= | 57 | | set | set | =new Set($0);= | 58 | | spr | spread | =(...$1)$0= | 59 | | si | stringInterpolate | =${$0}= | 60 | | sup | super | =super($0)= | 61 | | sym | symbol | =Symbol($0);= | 62 | | ts | templateString | =`$0`= | 63 | | wmap | weakMap | =new WeakMap($0);= | 64 | | wset | weakSet | =new WeakSet($0);= | 65 | 66 | 67 | ** Contributing 68 | Please do. Open an issue or a pull request if you need a snippet 69 | added, want to discuss changing a key binding, or have any issues. 70 | 71 | I know I didn't get to all of them, and there are some I 72 | intentionally left off, but I'm open to adding or changing any snippets. 73 | 74 | - [ ] Shorter bindings. If I can figure out there won't be clashed with the other JavaScript 75 | Yasnippets, I would like to shorten some of these key bindings. 76 | - [ ] Full coverage for EcmaScript 2015 77 | - [ ] MELPA package 78 | 79 | ** License 80 | **** This software is licensed under the GNU General Publice License Version 3.0 81 | 82 | This program is free software: you can redistribute it and/or 83 | modify it under the terms of the GNU General Public License as 84 | published by the Free Software Foundation, either version 3 of the 85 | License, or (at your option) any later version. This program is 86 | distributed in the hope that it will be useful, but WITHOUT ANY 87 | WARRANTY; without even the implied warranty of MERCHANTABILITY or 88 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 89 | License for more details. You should have received a copy of the 90 | GNU General Public License along with this program. If not, see 91 | http://www.gnu.org/licenses/ 92 | --------------------------------------------------------------------------------