Improve smartparens+web-mode compatibility
+ Enables web-mode's autopairing functionality + Prevents duplicate >'s after web-mode autopairing. + Leave longer-than-3-character pairs to smartparens (there was only <!-- -->) + Remove <?p -> <?php | ?> autopairer. Leave that to snippets (web-mode doesn't support prefixes longer than 3 letters, and <?php ?> is too much of a performance drain to have smartparens support it, so I added a "php" snippet that expands to <?php | ?>). + Tags now auto-close when you finish typing the opening tag. (web-mode-auto-close-style = 2)
This commit is contained in:
parent
88ee423806
commit
0ee42c1df0
1 changed files with 19 additions and 1 deletions
|
@ -16,7 +16,25 @@
|
||||||
:mode "templates/.+\\.php$"
|
:mode "templates/.+\\.php$"
|
||||||
:config
|
:config
|
||||||
(setq web-mode-enable-html-entities-fontification t
|
(setq web-mode-enable-html-entities-fontification t
|
||||||
web-mode-enable-auto-quoting nil)
|
web-mode-auto-close-style 2)
|
||||||
|
|
||||||
|
(after! smartparens
|
||||||
|
;; 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 <?p and
|
||||||
|
;; hp ?>.
|
||||||
|
(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)))))
|
||||||
|
(setf (alist-get nil web-mode-engines-auto-pairs) nil))
|
||||||
|
|
||||||
(map! :map web-mode-map
|
(map! :map web-mode-map
|
||||||
(:localleader
|
(:localleader
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue