Move c electric disabler to config/default
Because it is tied to the smartparens config, and we'll want this behavior to extend to all C-derived modes (like csharp and php modes).
This commit is contained in:
parent
94b16cba6c
commit
9dd88e5924
2 changed files with 11 additions and 9 deletions
|
@ -64,6 +64,16 @@
|
||||||
(sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode))
|
(sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode))
|
||||||
"<!--" "-->" :actions '(insert) :post-handlers '(("| " "SPC")))
|
"<!--" "-->" :actions '(insert) :post-handlers '(("| " "SPC")))
|
||||||
|
|
||||||
|
;; Disable electric keys in C modes because it interferes with smartparens
|
||||||
|
;; and custom bindings. We'll do it ourselves (mostly).
|
||||||
|
(after! cc-mode
|
||||||
|
(c-toggle-electric-state -1)
|
||||||
|
(c-toggle-auto-newline -1)
|
||||||
|
(setq c-tab-always-indent nil
|
||||||
|
c-electric-flag nil)
|
||||||
|
(dolist (key '("#" "{" "}" "/" "*" ";" "," ":" "(" ")" "\177"))
|
||||||
|
(define-key c-mode-base-map key nil)))
|
||||||
|
|
||||||
;; Expand C-style doc comment blocks. Must be done manually because some of
|
;; Expand C-style doc comment blocks. Must be done manually because some of
|
||||||
;; these languages use specialized (and deferred) parsers, whose state we
|
;; these languages use specialized (and deferred) parsers, whose state we
|
||||||
;; can't access while smartparens is doing its thing.
|
;; can't access while smartparens is doing its thing.
|
||||||
|
|
|
@ -106,24 +106,16 @@ compilation database is present in the project.")
|
||||||
c-style-alist))
|
c-style-alist))
|
||||||
|
|
||||||
;;; Keybindings
|
;;; Keybindings
|
||||||
;; Disable electric keys because it interferes with smartparens and custom
|
|
||||||
;; bindings. We'll do it ourselves (mostly).
|
|
||||||
(c-toggle-electric-state -1)
|
|
||||||
(c-toggle-auto-newline -1)
|
|
||||||
(setq c-tab-always-indent nil
|
|
||||||
c-electric-flag nil)
|
|
||||||
(dolist (key '("#" "}" "/" "*" ";" "," ":" "(" ")" "\177"))
|
|
||||||
(define-key c-mode-base-map key nil))
|
|
||||||
;; Smartparens and cc-mode both try to autoclose angle-brackets intelligently.
|
;; Smartparens and cc-mode both try to autoclose angle-brackets intelligently.
|
||||||
;; The result isn't very intelligent (causes redundant characters), so just do
|
;; The result isn't very intelligent (causes redundant characters), so just do
|
||||||
;; it ourselves.
|
;; it ourselves.
|
||||||
(define-key! c++-mode-map "<" nil ">" nil)
|
(define-key! c++-mode-map "<" nil ">" nil)
|
||||||
|
|
||||||
;; ...and leave it to smartparens
|
;; ...and leave it to smartparens
|
||||||
(sp-with-modes '(c++-mode objc-mode)
|
(sp-with-modes '(c++-mode objc-mode)
|
||||||
(sp-local-pair "<" ">"
|
(sp-local-pair "<" ">"
|
||||||
:when '(+cc-sp-point-is-template-p +cc-sp-point-after-include-p)
|
:when '(+cc-sp-point-is-template-p +cc-sp-point-after-include-p)
|
||||||
:post-handlers '(("| " "SPC"))))
|
:post-handlers '(("| " "SPC"))))
|
||||||
|
|
||||||
(sp-with-modes '(c-mode c++-mode objc-mode java-mode)
|
(sp-with-modes '(c-mode c++-mode objc-mode java-mode)
|
||||||
(sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC")))))
|
(sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC")))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue