yasnippet configuration

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
; Activate yasnippet
; (fingers crossed that it will not break anything like it used to)
(require 'yasnippet)
(yas-global-mode 1)
    ;; Develop and keep personal snippets under ~/.emacs.d/mysnippets
    ;; Note: occasionally have to update copiled cache with yas-recompile-all
    (setq yas/root-directory "~/.emacs.d/snippets")

    ;; Load the snippets
    (yas/load-directory yas/root-directory)

    ;; TODO these don't work!
    ;; When writing snippets, go to the next field of the snippet with
    ;; C-<tab>. This fixes an annoyance where tab completion in
    ;; auto-complete will not work, and the next field is selected
    ;; instead.
    (setq yas/next-field-key "C-,")
    (setq yas/prev-field-key "C-;")

    ;; If non-nil, yas/next-field-key can trigger stacked expansions,
    ;; that is a snippet expansion inside another snippet
    ;; expansion. Otherwise, yas/next-field-key just tries to move on
    ;; to the next field.
    (setq yas/triggers-in-field t)

    ;; Insert snippets with C-c C-a.
    (define-key global-map (kbd "C-c C-a") 'yas-insert-snippet)

    ;; Start to fill a snippet with TAB
    (setq yas/trigger-key "<tab>")
    ;; Show snippets in the popup menu auto-complete-mode uses by default.
    (load-file "~/.emacs.d/yasnippet-popup-isearch-prompt.el")