diff --git a/core/core-editor.el b/core/core-editor.el index 7e6287bf3..3142fe157 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -29,9 +29,6 @@ (sp-with-modes '(json-mode js2-mode ruby-mode enh-ruby-mode python-mode) (sp-local-pair "[" nil :post-handlers '(("||\n[i]" "RET")))) - ;; Let web-mode handle autopairing - (sp-local-pair 'web-mode "<" nil :actions nil) - (after "yasnippet" (defadvice yas-expand (before advice-for-yas-expand activate) (sp-remove-active-pair-overlay))))) diff --git a/init/init-web.el b/init/init-web.el index b07ce7117..27ffed7b6 100644 --- a/init/init-web.el +++ b/init/init-web.el @@ -22,6 +22,17 @@ web-mode-script-padding 2 web-mode-block-padding 2) + (after "smartparens" + (add-hook! 'web-mode-hook (setq web-mode-enable-auto-pairing nil)) + + (defun sp-web-mode-is-code-context (id action context) + (when (and (eq action 'insert) + (not (or (get-text-property (point) 'part-side) + (get-text-property (point) 'block-side)))) + t)) + + (sp-local-pair 'web-mode "<" nil :when '(sp-web-mode-is-code-context))) + (after "web-beautify" (add-hook! 'web-mode-hook (setenv "jsbeautify_indent_size" "4")) (bind 'motion web-mode-map "gQ" 'web-beautify-html))