From 1558c4461a8398a7e44fa963bb1076fcbd895863 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 12 May 2021 11:02:33 -0400 Subject: [PATCH] Improve smartparens in web-mode and JS modes --- emacs/.emacs.d/config/init-editing.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/emacs/.emacs.d/config/init-editing.el b/emacs/.emacs.d/config/init-editing.el index 4b98d08..d4eacfa 100644 --- a/emacs/.emacs.d/config/init-editing.el +++ b/emacs/.emacs.d/config/init-editing.el @@ -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)