Improve smartparens in web-mode and JS modes

This commit is contained in:
Jeremy Dormitzer 2021-05-12 11:02:33 -04:00
parent 7f6f3c1233
commit 1558c4461a

View File

@ -20,6 +20,19 @@
(defun sp-wrap-single-quote ()
(interactive)
(sp-wrap-with-pair "'"))
(defun sp-after-equals-p (_id action _context)
(when (memq action '(insert navigate))
(sp--looking-back-p "=>" 2)))
;; Enable ES6 arrow functions in web mode
(defun sp-after-equals-skip-p (ms mb _me)
(when (eq ms ">")
(save-excursion
(goto-char mb)
(sp--looking-back-p "=" 1))))
(sp-local-pair '(web-mode) "<" nil
:unless '(:add sp-after-equals-p)
:skip-match 'sp-after-equals-skip-p)
:hook
(prog-mode . smartparens-strict-mode)
(eshell-mode . smartparens-strict-mode)