feature/snippets: remove evil hacks (experimental)
They don't seem to be necessary anymore. More testing is required.
This commit is contained in:
parent
16df33a5b1
commit
9fa60965a8
1 changed files with 2 additions and 21 deletions
|
@ -38,27 +38,8 @@
|
|||
;; fix an error caused by smartparens interfering with yasnippet bindings
|
||||
(advice-add #'yas-expand :before #'sp-remove-active-pair-overlay)
|
||||
|
||||
(after! evil
|
||||
;; Exit snippets on ESC in normal mode
|
||||
(add-hook '+evil-esc-hook #'yas-exit-all-snippets)
|
||||
;; Once you're in normal mode, you're out
|
||||
(add-hook 'evil-normal-state-entry-hook #'yas-abort-snippet)
|
||||
;; Strip out whitespace before a line selection
|
||||
(defun +snippets|yas-before-expand ()
|
||||
"Strip out the shitespace before a line selection."
|
||||
(when (and (evil-visual-state-p)
|
||||
(eq (evil-visual-type) 'line))
|
||||
(setq yas-selected-text
|
||||
(replace-regexp-in-string
|
||||
"\\(^\\s-*\\|\n? $\\)" ""
|
||||
(buffer-substring-no-properties evil-visual-beginning
|
||||
evil-visual-end)))))
|
||||
(add-hook 'yas-before-expand-snippet-hook #'+snippets|yas-before-expand)
|
||||
|
||||
(defun +snippets|yas-after-expand ()
|
||||
"Fix previous hook persisting yas-selected-text between expansions."
|
||||
(setq yas-selected-text nil))
|
||||
(add-hook 'yas-after-exit-snippet-hook #'+snippets|yas-after-expand)))
|
||||
;; Exit snippets on ESC from normal mode
|
||||
(add-hook '+evil-esc-hook #'yas-exit-all-snippets))
|
||||
|
||||
|
||||
(def-package! auto-yasnippet
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue