Smartparens mode gets disabled after auto-completing with yasnippet in Go mode.
Reproduction guide :beetle:
Start Emacs
Ensure you have Go and auto-complete layers enabled
Create a Go buffer
Type func and press M-/. The function snippet will be activated.
Type the function name, then press TAB to enter the func arguments, type any argument e.g. x int press TAB again
Type the return type, e.g. int press TAB. It should activate the comments line, and pressing again should move the caret to function body
Press ESC and type any paired char, e.g. {". It should automatically insert the closing char, but it doesn't, because the smartparens mode is off now.
Pressing SPC+t+p will enable the smartparens mode
Observed behaviour: :eyes: :broken_heart:
Smartparens becomes disabled when the auto-complete is triggered for multi-level yasnippet snippets.
Expected behaviour: :heart: :smile:
Smartparens mode should still be enabled after the yasnippet/auto-completion has finished.
Potential solution:
I found a possible solution for the above and it seems to work, so I'm keen to raise a PR for it.
Basically, given that the smartparens is disabled in the auto-completion hook, the spacemacs--smartparens-enabled-initially seems to lose its original value when there's are nested snippets. So the fix is to ensure that the original value (enabled) is preserved.
(defvar spacemacs--smartparens-enabled-initially nil
"Stored whether smartparens is originally enabled or not.")
(defun spacemacs//smartparens-disable-before-expand-snippet ()
"Handler for `yas-before-expand-snippet-hook'.
Disable smartparens and remember its initial state."
;; Remember the initial smartparens state only once, when expanding a top-level snippet.
(setq spacemacs--smartparens-enabled-initially (or spacemacs--smartparens-enabled-initially smartparens-mode smartparens-strict-mode))
(spacemacs//deactivate-smartparens))
Description :octocat:
Smartparens mode gets disabled after auto-completing with yasnippet in Go mode.
Reproduction guide :beetle:
func
and pressM-/
. The function snippet will be activated.x int
press TAB againint
press TAB. It should activate the comments line, and pressing again should move the caret to function body{
"
. It should automatically insert the closing char, but it doesn't, because the smartparens mode is off now.Observed behaviour: :eyes: :broken_heart:
Expected behaviour: :heart: :smile:
Potential solution:
spacemacs--smartparens-enabled-initially
seems to lose its original value when there's are nested snippets. So the fix is to ensure that the original value (enabled) is preserved.System Info :computer:
Backtrace :paw_prints: