Emacs Yasnippet Library
My personal yasnippet snippets for my emacs.d.
Notes to snippet authors
-
%is aliased toyas-selected-textfor convenience. -
My emacs config has project-specific minor modes. A
+prefix denotes these minor modes, e.g.+php-laravel-mode. -
This library uses a lot of custom helper functions, like
(!%!)and(%1). These are defined infundamental-mode/.yas-setup.el. See their docstrings to see what they do. -
The
(%alias TRIGGER &optional MODE)function is available for setting up multiple triggers for one snippet. e.g.;; js-mode/class # name: class # -- class ${1:Name} { $0 } ;; js-mode/cl # name: class # uuid: cl # type: command # -- (%alias "class")
Note: if your alias snippets share the same
name, they must have a uniqueuuid.
Install
Clone this repo somewhere, then add its directory to load-path, and...
(require 'emacs-snippets)
;; OR
(use-package emacs-snippets :after yasnippet)emacs-snippets sets itself up when yasnippet first loads.
If you're using Doom Emacs, place this in any module's packages.el:
(package! emacs-snippets
:recipe (:fetcher github
:repo "hlissner/emacs-snippets"
:files ("*")))Note: if you use yas-minor-mode (instead of yas-global-mode), you must manually
call yas-reload-all. Doom does this in feature/snippets for you:
;; Ensure `yas-reload-all' is called as late as possible. Other modules could
;; have additional configuration for yasnippet. For example, file-templates.
(add-transient-hook! 'yas-minor-mode-hook (yas-reload-all))