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))
|
||||
(add-hook 'after-change-major-mode-hook #'doom|disable-smartparens-navigate-skip-match)
|
||||
|
||||
;; smartparenss conflicts with evil-mode's replace state
|
||||
(add-hook 'evil-replace-state-entry-hook #'turn-off-smartparens-mode)
|
||||
(add-hook 'evil-replace-state-exit-hook #'turn-on-smartparens-mode)
|
||||
|
||||
;; autopairing in `eval-expression' and `evil-ex'
|
||||
(defun doom|init-smartparens-in-eval-expression ()
|
||||
"Enable `smartparens-mode' in the minibuffer, during `eval-expression' or
|
||||
`evil-ex'."
|
||||
|
@ -169,16 +166,9 @@ fundamental-mode) for performance sake."
|
|||
(add-hook 'minibuffer-setup-hook #'doom|init-smartparens-in-eval-expression)
|
||||
(sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
|
||||
|
||||
(sp-local-pair sp--html-modes "<!--" "-->"
|
||||
: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]" "*")))
|
||||
;; smartparenss conflicts with evil-mode's replace state
|
||||
(add-hook 'evil-replace-state-entry-hook #'turn-off-smartparens-mode)
|
||||
(add-hook 'evil-replace-state-exit-hook #'turn-on-smartparens-mode)
|
||||
|
||||
(smartparens-global-mode +1))
|
||||
|
||||
|
|
|
@ -44,10 +44,6 @@
|
|||
(sp-local-pair 'ruby-mode "{" "}"
|
||||
:pre-handlers '(:rem sp-ruby-prehandler)
|
||||
: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 {|} => {
|
||||
|
@ -63,6 +59,18 @@
|
|||
(sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode)
|
||||
"[" 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:
|
||||
;; a) balance spaces inside brackets/parentheses ( | ) -> (|)
|
||||
;; b) delete space-indented `tab-width' steps at a time
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
(def-package! elixir-mode
|
||||
:defer t
|
||||
:init
|
||||
;; disable default smartparens config
|
||||
(provide 'smartparens-elixir)
|
||||
:config
|
||||
;; ...and only complete the basics
|
||||
(after! smartparens
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
;; Plugins
|
||||
;;
|
||||
|
||||
;; sp's default rules are obnoxious, so disable them
|
||||
(provide 'smartparens-latex)
|
||||
|
||||
(after! tex
|
||||
;; Set some varibles to fontify common LaTeX commands.
|
||||
(load! "+fontification")
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
;;; lang/lua/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; sp's default rules are obnoxious, so disable them
|
||||
(provide 'smartparens-lua)
|
||||
|
||||
(after! lua-mode
|
||||
(set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation)
|
||||
(set-electric! 'lua-mode :words '("else" "end"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue