diff --git a/modules/lang/web/+html.el b/modules/lang/web/+html.el
index 5c8af811e..3c33cc562 100644
--- a/modules/lang/web/+html.el
+++ b/modules/lang/web/+html.el
@@ -19,21 +19,26 @@
web-mode-auto-close-style 2)
(after! smartparens
+ (defun +web-is-auto-close-style-3 (_id action _context)
+ (and (eq action 'insert)
+ (eq web-mode-auto-close-style 3)))
+ (sp-local-pair 'web-mode "<" nil :unless '(:add +web-is-auto-close-style-3))
+
;; let smartparens handle these
(setq web-mode-enable-auto-quoting nil
web-mode-enable-auto-pairing t)
- ;; Remove web-mode auto pairs that end with >, because smartparens autopairs
- ;; them, causing duplicates. Also remove truncated autopairs, like .
+
+ ;; 1. Remove web-mode auto pairs whose end pair starts with a latter
+ ;; (truncated autopairs like ). Smartparens handles these
+ ;; better.
+ ;; 2. Strips out extra closing pairs to prevent redundant characters
+ ;; inserted by smartparens.
(dolist (alist web-mode-engines-auto-pairs)
- (setcdr alist (delq nil
- (mapcar (lambda (pair)
- (unless (string-match-p "^[a-z-]" (cdr pair))
- (cons (car pair)
- (if (equal (substring (cdr pair) -1) ">")
- (substring (cdr pair) 0 -1)
- (cdr pair)))))
- (cdr alist)))))
+ (setcdr alist
+ (cl-loop for pair in (cdr alist)
+ unless (string-match-p "^[a-z-]" (cdr pair))
+ collect (cons (car pair)
+ (string-trim-right (cdr pair) "\\(?:>\\|]\\|}\\)+")))))
(setf (alist-get nil web-mode-engines-auto-pairs) nil))
(map! :map web-mode-map