Skip to content

Commit

Permalink
Fix smartparens workaround in auto-completion
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBB committed Dec 3, 2015
1 parent 87b6d3f commit 13db87c
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions layers/auto-completion/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
hippie-exp
yasnippet
auto-yasnippet
smartparens
))

;; company-quickhelp from MELPA is not compatible with 24.3 anymore
Expand Down Expand Up @@ -261,21 +262,7 @@
(spacemacs/add-to-hooks 'spacemacs/force-yasnippet-off '(term-mode-hook
shell-mode-hook
eshell-mode-hook)))
:config
(progn
;; We need to know whether the smartparens was enabled, see
;; `yas-before-expand-snippet-hook' below.
(defvar smartparens-enabled-initially t
"Stored whether smartparens is originally enabled or not.")

(add-hook 'yas-before-expand-snippet-hook (lambda ()
;; If enabled, smartparens will mess snippets expanded by `hippie-expand`
(setq smartparens-enabled-initially smartparens-mode)
(smartparens-mode -1)))
(add-hook 'yas-after-exit-snippet-hook (lambda ()
(when smartparens-enabled-initially
(smartparens-mode 1))))
(spacemacs|diminish yas-minor-mode "" " y"))))
:config (spacemacs|diminish yas-minor-mode "" " y")))

(defun auto-completion/init-auto-yasnippet ()
(use-package auto-yasnippet
Expand All @@ -295,3 +282,19 @@
"iSc" 'aya-create
"iSe" 'spacemacs/auto-yasnippet-expand
"iSw" 'aya-persist-snippet))))

(defun auto-completion/post-init-smartparens ()
(with-eval-after-load 'smartparens
;; We need to know whether the smartparens was enabled, see
;; `yas-before-expand-snippet-hook' below.
(defvar smartparens-enabled-initially t
"Stored whether smartparens is originally enabled or not.")
(add-hook 'yas-before-expand-snippet-hook
(lambda ()
;; If enabled, smartparens will mess snippets expanded by `hippie-expand`
(setq smartparens-enabled-initially smartparens-mode)
(smartparens-mode -1)))
(add-hook 'yas-after-exit-snippet-hook
(lambda ()
(when smartparens-enabled-initially
(smartparens-mode 1))))))

0 comments on commit 13db87c

Please sign in to comment.