es6-snippets.el is a collection of Yanippets for writing EcmaScript 2015 in Emacs.
This is almost comprehensive, but snippets are still being changed and added.
See the ES6 Standard draft for a full spec.
First get the source:
$ git clone git@github.com:codyreichert/es6-snippets ~/.emacs.d/es6-snippets
Then require the package:
(add-to-list 'load-path "~/.emacs.d/es6-snippets")
(require 'es6-snippets)
There’s plenty of other ways, so do what works best for you
Yasnippets needs to be enabled, but once once it is and you’ve
required the package in your init.el, snippets will be available in
web-mode
, js2-mode
, or js-mode
.
Snippet | Name | Description |
---|---|---|
arw | arrowFunction | ($1) => { $0 } |
cl | class | class $1 { $0 } |
cle | classExtends | class $1 extends $2 { $0 } |
ccs | classConstructor | constructor($1) { $0 } |
const | constant | const $1 = $0; |
exp | export | export $0; |
expd | exportDefault | export default $0; |
expf | exportFunction | export function $1($2) { $0 } |
forof | forOfLoop | for($1 of $2) { $0 } |
imp | import | import $0; |
let | let | let $1 = $0; |
map | map | new Map($0); |
prom | promise | new Promise(($1) => { $0 }); |
px | proxy | new Proxy($1, $0); |
set | set | new Set($0); |
spr | spread | (...$1)$0 |
si | stringInterpolate | ${$0} |
sup | super | super($0) |
sym | symbol | Symbol($0); |
ts | templateString | `$0` |
wmap | weakMap | new WeakMap($0); |
wset | weakSet | new WeakSet($0); |
Please do. Open an issue or a pull request if you need a snippet added, want to discuss changing a key binding, or have any issues.
I know I didn’t get to all of them, and there are some I intentionally left off, but I’m open to adding or changing any snippets.
- [ ] Shorter bindings. If I can figure out there won’t be clashed with the other JavaScript Yasnippets, I would like to shorten some of these key bindings.
- [ ] Full coverage for EcmaScript 2015
- [ ] MELPA package