2016-04-23 22:08:46 -04:00
|
|
|
;;; core-yasnippet.el
|
2015-06-15 09:05:52 +02:00
|
|
|
|
|
|
|
(use-package yasnippet
|
2015-09-30 13:47:57 -04:00
|
|
|
:mode ("emacs\\.d/private/\\(snippets\\|templates\\)/.+$" . snippet-mode)
|
2015-06-15 09:05:52 +02:00
|
|
|
:commands (yas-minor-mode
|
|
|
|
yas-minor-mode-on
|
|
|
|
yas-expand
|
|
|
|
yas-insert-snippet
|
|
|
|
yas-new-snippet
|
|
|
|
yas-visit-snippet-file)
|
|
|
|
:init
|
2016-05-20 19:08:02 -04:00
|
|
|
(defvar yas-minor-mode-map (make-sparse-keymap))
|
2015-06-15 09:05:52 +02:00
|
|
|
(setq yas-verbosity 0
|
|
|
|
yas-indent-line 'auto
|
|
|
|
yas-also-auto-indent-first-line t
|
|
|
|
yas-wrap-around-region nil
|
|
|
|
;; Only load personal snippets
|
2016-05-20 22:37:30 -04:00
|
|
|
yas-snippet-dirs doom-snippet-dirs
|
2015-06-15 09:05:52 +02:00
|
|
|
yas-prompt-functions '(yas-ido-prompt yas-no-prompt))
|
|
|
|
|
2016-04-21 00:46:02 -04:00
|
|
|
(add-hook! (text-mode prog-mode snippet-mode markdown-mode org-mode)
|
|
|
|
'yas-minor-mode-on)
|
|
|
|
|
|
|
|
:config
|
2015-06-15 09:05:52 +02:00
|
|
|
(yas-reload-all)
|
2016-05-20 19:08:02 -04:00
|
|
|
(map! :map yas-keymap
|
2016-05-20 22:37:30 -04:00
|
|
|
"C-e" 'doom/yas-goto-end-of-field
|
|
|
|
"C-a" 'doom/yas-goto-start-of-field
|
|
|
|
"<M-right>" 'doom/yas-goto-end-of-field
|
|
|
|
"<M-left>" 'doom/yas-goto-start-of-field
|
2016-05-20 19:08:02 -04:00
|
|
|
"<S-tab>" 'yas-prev-field
|
2016-05-20 22:37:30 -04:00
|
|
|
"<M-backspace>" 'doom/yas-clear-to-sof
|
2016-05-20 19:08:02 -04:00
|
|
|
"<escape>" 'evil-normal-state
|
2016-05-20 22:37:30 -04:00
|
|
|
[backspace] 'doom/yas-backspace
|
|
|
|
"<delete>" 'doom/yas-delete)
|
2015-06-15 09:05:52 +02:00
|
|
|
|
2016-05-20 19:08:02 -04:00
|
|
|
;; Exit snippets on ESC in normal mode
|
|
|
|
(advice-add 'evil-force-normal-state :before 'yas-exit-all-snippets)
|
|
|
|
;; Fix an issue with smartparens interfering with yasnippet keybindings
|
|
|
|
(advice-add 'yas-expand :before 'sp-remove-active-pair-overlay)
|
2015-06-15 09:05:52 +02:00
|
|
|
;; Once you're in normal mode, you're out
|
2016-04-21 00:46:02 -04:00
|
|
|
(add-hook 'evil-normal-state-entry-hook 'yas-abort-snippet)
|
2016-05-18 02:14:44 -04:00
|
|
|
;; Strip out whitespace before a line selection
|
2016-05-20 22:37:30 -04:00
|
|
|
(add-hook 'yas-before-expand-snippet-hook 'doom|yas-before-expand)
|
2016-05-18 02:14:44 -04:00
|
|
|
;; Fix previous hook persisting yas-selected-text between expansions
|
2016-05-20 22:37:30 -04:00
|
|
|
(add-hook 'yas-after-exit-snippet-hook 'doom|yas-after-expand))
|
2015-06-15 09:05:52 +02:00
|
|
|
|
2016-02-26 17:59:14 -05:00
|
|
|
(use-package auto-yasnippet
|
|
|
|
:commands (aya-create aya-expand aya-open-line aya-persist-snippet)
|
|
|
|
:config
|
2016-05-20 22:37:30 -04:00
|
|
|
(setq aya-persist-snippets-dir (concat doom-private-dir "auto-snippets/")))
|
2016-01-30 21:16:10 -05:00
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
(provide 'core-yasnippet)
|
|
|
|
;;; core-yasnippet.el ends here
|