From 4b13812edaf568e237dbfab6cbd8071455ee261f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 18 May 2016 02:14:44 -0400 Subject: [PATCH] Clean up yasnippet config --- core/core-yasnippet.el | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/core/core-yasnippet.el b/core/core-yasnippet.el index 98738618e..77b829492 100644 --- a/core/core-yasnippet.el +++ b/core/core-yasnippet.el @@ -34,41 +34,38 @@ (associate! snippet-mode :match "emacs\\.d/private/\\(snippets\\|templates\\)/.+$") - ;; Undo global maps (map! :i [(tab)] nil - :v "" nil) + :v "" nil - ;; keybinds - (map! :map yas-keymap - "C-e" 'narf/yas-goto-end-of-field - "C-a" 'narf/yas-goto-start-of-field - "" 'narf/yas-goto-end-of-field - "" 'narf/yas-goto-start-of-field - "" 'yas-prev-field - "" 'narf/yas-clear-to-sof + (:map yas-keymap + "C-e" 'narf/yas-goto-end-of-field + "C-a" 'narf/yas-goto-start-of-field + "" 'narf/yas-goto-end-of-field + "" 'narf/yas-goto-start-of-field + "" 'yas-prev-field + "" 'narf/yas-clear-to-sof - "" 'evil-normal-state - [backspace] 'narf/yas-backspace - "" 'narf/yas-delete) + "" 'evil-normal-state + [backspace] 'narf/yas-backspace + "" 'narf/yas-delete)) - ;; Prevents evil's visual-line from gobbling up the newline on the right due to an - ;; off-by-one issue. + ;; Prevents evil's visual-line from gobbling up the newline on the right due + ;; to an off-by-one issue. (defadvice yas-expand-snippet (around yas-expand-snippet-visual-line activate) (when (narf/evil-visual-line-state-p) (ad-set-arg 2 (1- (ad-get-arg 2)))) ad-do-it) ;; Once you're in normal mode, you're out (add-hook 'evil-normal-state-entry-hook 'yas-abort-snippet) - ;; Strip out the shitespace before a line selection + ;; Strip out whitespace before a line selection (add-hook 'yas-before-expand-snippet-hook 'narf|yas-before-expand) - ;; Previous hook causes yas-selected-text to persist between expansions. - ;; This little hack fixes that. + ;; Fix previous hook persisting yas-selected-text between expansions (add-hook 'yas-after-exit-snippet-hook 'narf|yas-after-expand) ;; Exit snippets on ESC in normal mode (advice-add 'evil-force-normal-state :before 'yas-exit-all-snippets) - ;; Fix an issue with smartparens' keybindings interfering with yasnippet keybindings. + ;; Fix an issue with smartparens interfering with yasnippet keybindings (advice-add 'yas-expand :before 'sp-remove-active-pair-overlay)) (use-package auto-yasnippet