Enable ES6 arrow functions in web-mode with smartparens-strict-mode

This commit is contained in:
Jeremy Dormitzer 2020-02-05 15:46:08 -05:00
parent a214be7103
commit 886a65f328

View File

@ -1335,6 +1335,23 @@ Smartparens enables structured editing of s-expressions and other pairs:
(leader-def-key "lb" 'sp-forward-barf-sexp) (leader-def-key "lb" 'sp-forward-barf-sexp)
#+END_SRC #+END_SRC
Enable ES6 arrow functions in web-mode ("borrowed" from [[https://github.com/Fuco1/smartparens/issues/823#issuecomment-403019519][this GitHub comment]]):
#+BEGIN_SRC emacs-lisp
(defun sp-after-equals-p (_id action _context)
(when (memq action '(insert navigate))
(sp--looking-back-p "=>" 2)))
(defun sp-after-equals-skip (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)
#+END_SRC
Parinfer infers parens from indentation and vice-versa: Parinfer infers parens from indentation and vice-versa:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package parinfer (use-package parinfer