Fix yasnippet+hippie-expand interop
This commit is contained in:
parent
1dfe690f36
commit
7a868b1537
1 changed files with 25 additions and 0 deletions
|
@ -93,6 +93,31 @@
|
|||
:filter-return #'yas--all-templates
|
||||
(cl-delete-duplicates templates :test #'equal))
|
||||
|
||||
;; HACK Smartparens will interfere with snippets expanded by `hippie-expand`,
|
||||
;; so temporarily disable smartparens during snippet expansion.
|
||||
(after! hippie-exp
|
||||
(defvar +snippets--smartparens-enabled-p t)
|
||||
(defvar +snippets--expanding-p nil)
|
||||
|
||||
;; Is called for all snippet expansions,
|
||||
(add-hook! 'yas-before-expand-snippet-hook
|
||||
(defun +snippets--disable-smartparens-before-expand-h ()
|
||||
;; Remember the initial smartparens state only once, when expanding a
|
||||
;; top-level snippet.
|
||||
(unless +snippets--expanding-p
|
||||
(setq +snippets--expanding-p t
|
||||
+snippets--smartparens-enabled-p smartparens-mode))
|
||||
(when smartparens-mode
|
||||
(smartparens-mode -1))))
|
||||
|
||||
;; Is called only for the top level snippet, but not for the nested ones.
|
||||
;; Hence `+snippets--expanding-p'.
|
||||
(add-hook! 'yas-after-exit-snippet-hook
|
||||
(defun +snippets--restore-smartparens-after-expand-h ()
|
||||
(setq +snippets--expanding-p nil)
|
||||
(when +snippets--smartparens-enabled-p
|
||||
(smartparens-mode 1)))))
|
||||
|
||||
;; If in a daemon session, front-load this expensive work:
|
||||
(if (daemonp) (yas-reload-all)))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue