From 886a65f3280a9017713ba8f9cbb7c60c1e4bbe49 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 5 Feb 2020 15:46:08 -0500 Subject: [PATCH] Enable ES6 arrow functions in web-mode with smartparens-strict-mode --- emacs/init.org | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/emacs/init.org b/emacs/init.org index 22bc838..5d9ac0a 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -1335,6 +1335,23 @@ Smartparens enables structured editing of s-expressions and other pairs: (leader-def-key "lb" 'sp-forward-barf-sexp) #+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: #+BEGIN_SRC emacs-lisp (use-package parinfer