Refactor smartparens default rules
Move them to config/default, but move single-lang-specific ones to their respective modules.
This commit is contained in:
parent
1d7782aea3
commit
8a4f15b01c
5 changed files with 25 additions and 18 deletions
|
@ -157,10 +157,7 @@ fundamental-mode) for performance sake."
|
||||||
sp-navigate-consider-sgml-tags nil))
|
sp-navigate-consider-sgml-tags nil))
|
||||||
(add-hook 'after-change-major-mode-hook #'doom|disable-smartparens-navigate-skip-match)
|
(add-hook 'after-change-major-mode-hook #'doom|disable-smartparens-navigate-skip-match)
|
||||||
|
|
||||||
;; smartparenss conflicts with evil-mode's replace state
|
;; autopairing in `eval-expression' and `evil-ex'
|
||||||
(add-hook 'evil-replace-state-entry-hook #'turn-off-smartparens-mode)
|
|
||||||
(add-hook 'evil-replace-state-exit-hook #'turn-on-smartparens-mode)
|
|
||||||
|
|
||||||
(defun doom|init-smartparens-in-eval-expression ()
|
(defun doom|init-smartparens-in-eval-expression ()
|
||||||
"Enable `smartparens-mode' in the minibuffer, during `eval-expression' or
|
"Enable `smartparens-mode' in the minibuffer, during `eval-expression' or
|
||||||
`evil-ex'."
|
`evil-ex'."
|
||||||
|
@ -169,16 +166,9 @@ fundamental-mode) for performance sake."
|
||||||
(add-hook 'minibuffer-setup-hook #'doom|init-smartparens-in-eval-expression)
|
(add-hook 'minibuffer-setup-hook #'doom|init-smartparens-in-eval-expression)
|
||||||
(sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
|
(sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
|
||||||
|
|
||||||
(sp-local-pair sp--html-modes "<!--" "-->"
|
;; smartparenss conflicts with evil-mode's replace state
|
||||||
:actions '(insert) :post-handlers '(("| " "SPC")))
|
(add-hook 'evil-replace-state-entry-hook #'turn-off-smartparens-mode)
|
||||||
|
(add-hook 'evil-replace-state-exit-hook #'turn-on-smartparens-mode)
|
||||||
(sp-local-pair
|
|
||||||
'(js2-mode typescript-mode rjsx-mode rust-mode
|
|
||||||
c-mode c++-mode objc-mode java-mode php-mode
|
|
||||||
css-mode scss-mode less-css-mode stylus-mode)
|
|
||||||
"/*" "*/"
|
|
||||||
:actions '(insert)
|
|
||||||
:post-handlers '(("| " "SPC") ("|\n*/[i][d-2]" "RET") ("\n* ||\n*/[i][d-2]" "*")))
|
|
||||||
|
|
||||||
(smartparens-global-mode +1))
|
(smartparens-global-mode +1))
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,6 @@
|
||||||
(sp-local-pair 'ruby-mode "{" "}"
|
(sp-local-pair 'ruby-mode "{" "}"
|
||||||
:pre-handlers '(:rem sp-ruby-prehandler)
|
:pre-handlers '(:rem sp-ruby-prehandler)
|
||||||
:post-handlers '(:rem sp-ruby-posthandler))
|
:post-handlers '(:rem sp-ruby-posthandler))
|
||||||
;; sp's default rules for these modes are obnoxious, so disable them
|
|
||||||
(provide 'smartparens-elixir)
|
|
||||||
(provide 'smartparens-latex)
|
|
||||||
(provide 'smartparens-lua)
|
|
||||||
|
|
||||||
;; Expand {|} => { | }
|
;; Expand {|} => { | }
|
||||||
;; Expand {|} => {
|
;; Expand {|} => {
|
||||||
|
@ -63,6 +59,18 @@
|
||||||
(sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode)
|
(sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode)
|
||||||
"[" nil :post-handlers '(:rem ("| " "SPC")))
|
"[" nil :post-handlers '(:rem ("| " "SPC")))
|
||||||
|
|
||||||
|
;; Reasonable default pairs for comments
|
||||||
|
(sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode))
|
||||||
|
"<!--" "-->" :actions '(insert) :post-handlers '(("| " "SPC")))
|
||||||
|
|
||||||
|
(sp-local-pair
|
||||||
|
'(js2-mode typescript-mode rjsx-mode rust-mode
|
||||||
|
c-mode c++-mode objc-mode java-mode php-mode
|
||||||
|
css-mode scss-mode less-css-mode stylus-mode)
|
||||||
|
"/*" "*/"
|
||||||
|
:actions '(insert)
|
||||||
|
:post-handlers '(("| " "SPC") ("|\n*/[i][d-2]" "RET") ("\n* ||\n*/[i][d-2]" "*")))
|
||||||
|
|
||||||
;; Highjacks backspace to:
|
;; Highjacks backspace to:
|
||||||
;; a) balance spaces inside brackets/parentheses ( | ) -> (|)
|
;; a) balance spaces inside brackets/parentheses ( | ) -> (|)
|
||||||
;; b) delete space-indented `tab-width' steps at a time
|
;; b) delete space-indented `tab-width' steps at a time
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
(def-package! elixir-mode
|
(def-package! elixir-mode
|
||||||
:defer t
|
:defer t
|
||||||
|
:init
|
||||||
|
;; disable default smartparens config
|
||||||
|
(provide 'smartparens-elixir)
|
||||||
:config
|
:config
|
||||||
;; ...and only complete the basics
|
;; ...and only complete the basics
|
||||||
(after! smartparens
|
(after! smartparens
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
;; Plugins
|
;; Plugins
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
;; sp's default rules are obnoxious, so disable them
|
||||||
|
(provide 'smartparens-latex)
|
||||||
|
|
||||||
(after! tex
|
(after! tex
|
||||||
;; Set some varibles to fontify common LaTeX commands.
|
;; Set some varibles to fontify common LaTeX commands.
|
||||||
(load! "+fontification")
|
(load! "+fontification")
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
;;; lang/lua/config.el -*- lexical-binding: t; -*-
|
;;; lang/lua/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; sp's default rules are obnoxious, so disable them
|
||||||
|
(provide 'smartparens-lua)
|
||||||
|
|
||||||
(after! lua-mode
|
(after! lua-mode
|
||||||
(set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation)
|
(set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation)
|
||||||
(set-electric! 'lua-mode :words '("else" "end"))
|
(set-electric! 'lua-mode :words '("else" "end"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue