General cleanup + evil fixes
This commit is contained in:
parent
ed7d45e36b
commit
07301d29bf
2 changed files with 79 additions and 61 deletions
|
@ -25,7 +25,7 @@
|
|||
|
||||
shift-select-mode t
|
||||
tabify-regexp "^\t* [ \t]+"
|
||||
whitespace-style '(face tabs tab-mark)
|
||||
whitespace-style '(face tabs tab-mark trailing newline indentation newline-mark)
|
||||
whitespace-display-mappings
|
||||
'((tab-mark ?\t [?> ?\t])
|
||||
(newline-mark 10 [36 10])))
|
||||
|
@ -65,8 +65,6 @@ enable multiple minor modes for the same regexp.")
|
|||
|
||||
|
||||
;; Modes 'n hooks ;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(associate! sh-mode :match "/\\.?z\\(sh/?\\|profile\\|login\\|logout\\|shrc\\|shenv\\)$")
|
||||
(associate! applescript-mode :match "\\.applescript$")
|
||||
(associate! emacs-lisp-mode :match "\\(/Cask\\|\\.\\(el\\|gz\\)\\)$")
|
||||
(associate! makefile-gmake-mode :match "/Makefile$")
|
||||
|
@ -104,8 +102,8 @@ enable multiple minor modes for the same regexp.")
|
|||
|
||||
;; (global-whitespace-mode 1) ; Show whitespace
|
||||
;; (global-font-lock-mode t) ; Enable syntax highlighting for older emacs
|
||||
(global-auto-revert-mode 1) ; revert buffers for changed files
|
||||
(electric-indent-mode -1) ; on by default
|
||||
(global-auto-revert-mode 1) ; revert buffers for changed files
|
||||
|
||||
;; window config undo/redo
|
||||
(setq winner-dont-bind-my-keys t)
|
||||
|
@ -118,8 +116,6 @@ enable multiple minor modes for the same regexp.")
|
|||
|
||||
(use-package undo-tree
|
||||
:config
|
||||
(defalias 'redo #'undo-tree-redo)
|
||||
(defalias 'undo #'undo-tree-undo)
|
||||
;; http://youtu.be/Z6woIRLnbmE
|
||||
(defadvice undo-tree-load-history-hook
|
||||
(around undo-tree-load-history-shut-up activate)
|
||||
|
@ -158,64 +154,78 @@ enable multiple minor modes for the same regexp.")
|
|||
:config
|
||||
(setq sp-autowrap-region nil ; let evil-surround handle this
|
||||
sp-highlight-pair-overlay nil
|
||||
sp-cancel-autoskip-on-backward-movement t
|
||||
sp-cancel-autoskip-on-backward-movement nil
|
||||
sp-show-pair-delay 0)
|
||||
|
||||
(smartparens-global-mode 1)
|
||||
(require 'smartparens-config)
|
||||
|
||||
;; Handle newlines + spaces
|
||||
;; Smartparens interferes with Replace mode
|
||||
(add-hook 'evil-replace-state-entry-hook 'turn-off-smartparens-mode)
|
||||
(add-hook 'evil-replace-state-exit-hook 'turn-on-smartparens-mode)
|
||||
|
||||
;; Auto-close more conservatively
|
||||
(sp-pair "{" "}" :post-handlers '(("||\n[i]" "RET") ("| " " "))
|
||||
:unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
(sp-pair "(" ")" :post-handlers '(("||\n[i]" "RET") ("| " " "))
|
||||
:unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
(sp-pair "[" "]" :post-handlers '(("| " " "))
|
||||
:unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
|
||||
;; Auto-close more conservatively
|
||||
(sp-pair "[" nil :unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
(sp-pair "'" nil :unless '(sp-point-after-word-p sp-point-before-word-p sp-point-before-same-p))
|
||||
(sp-pair "\"" nil :unless '(sp-point-after-word-p sp-point-before-word-p sp-point-before-same-p))
|
||||
(sp-local-pair 'markdown-mode "```" "```" :post-handlers '(("||\n[i]" "RET")))
|
||||
(sp-with-modes '(enh-ruby-mode python-mode shell-script-mode markdown-mode org-mode)
|
||||
(sp-local-pair "`" nil :unless '(sp-point-after-word-p sp-point-before-word-p sp-point-before-same-p)))
|
||||
(sp-with-modes '(json-mode js2-mode ruby-mode enh-ruby-mode python-mode)
|
||||
(sp-local-pair "[" nil :post-handlers '(("||\n[i]" "RET"))))
|
||||
(sp-with-modes '(c-mode c++-mode objc-mode java-mode scss-mode css-mode php-mode)
|
||||
(sp-local-pair "/* " " */" :post-handlers '(("||\n[i]" "RET")))
|
||||
(sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET"))))
|
||||
(sp-with-modes '(c-mode c++-mode objc-mode java-mode) ; Support for generics
|
||||
;; Support for generics/templates
|
||||
(sp-with-modes '(c-mode c++-mode objc-mode java-mode)
|
||||
(sp-local-pair "<" ">" :when '(sp-point-after-word-p) :unless '(sp-point-before-same-p)))
|
||||
(sp-with-modes '(objc-mode scss-mode css-mode)
|
||||
(sp-local-pair "/*\n" "\n */" :post-handlers '(("||[i]" "RET"))))
|
||||
(sp-with-modes '(c-mode c++-mode php-mode java-mode)
|
||||
(sp-local-pair "/*" "" :post-handlers '((" ||\n[i]*/" "RET"))))
|
||||
|
||||
(sp-local-pair '(sh-mode markdown-mode) "`" "`" :unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
(sp-local-pair 'markdown-mode "```" "```" :post-handlers '(("||\n[i]" "RET")) :unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
|
||||
(sp-local-pair '(scss-mode css-mode) "/*" "*/" :post-handlers '(("[d-3]||\n[i]" "RET") ("| " "SPC")))
|
||||
|
||||
(defun sp-insert-yasnippet (id action context)
|
||||
(forward-char -1)
|
||||
(if (sp-point-after-bol-p id action context)
|
||||
(yas-expand-from-trigger-key)
|
||||
(forward-char)))
|
||||
|
||||
(sp-with-modes '(sh-mode)
|
||||
(sp-local-pair "case" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "if" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "for" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "elif" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "while" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert)))
|
||||
|
||||
(sp-with-modes '(c-mode c++-mode objc-mode php-mode java-mode)
|
||||
(sp-local-pair "/*" "" :post-handlers '(("||\n[i]*/" "RET") ("| */" "SPC")))
|
||||
|
||||
;; Doxygen blocks
|
||||
(sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET") ("||\n[i]" "SPC")))
|
||||
(sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC"))))
|
||||
|
||||
(sp-with-modes '(org-mode)
|
||||
(sp-local-pair "\\[" "\\]")
|
||||
(sp-local-pair "\\(" "\\)")
|
||||
(sp-local-pair "$$" "$$")
|
||||
(sp-local-pair "\\[" "\\]" :post-handlers '(("| " "SPC")))
|
||||
(sp-local-pair "\\(" "\\)" :post-handlers '(("| " "SPC")))
|
||||
(sp-local-pair "$$" "$$" :post-handlers '((:add " | ")))
|
||||
(sp-local-pair "{" nil))
|
||||
|
||||
(after! yasnippet
|
||||
(advice-add 'yas-expand :before 'sp-remove-active-pair-overlay))
|
||||
;; Markup languages
|
||||
(sp-with-modes '(xml-mode nxml-mode php-mode)
|
||||
(sp-local-pair "<!--" "-->" :post-handlers '(("| " "SPC"))))
|
||||
(sp-with-modes '(web-mode php-mode)
|
||||
(sp-local-pair "<?" "?>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "<?php " " ?>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC"))))
|
||||
(sp-with-modes '(web-mode)
|
||||
(sp-local-pair "{{!--" "--}}" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "<%" "%>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "{!!" "!!}" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "{#" "#}" :post-handlers '(("||\n[i]" "RET") ("| " "SPC"))))
|
||||
|
||||
(after! web-mode
|
||||
(add-hook! web-mode (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! yasnippet
|
||||
;; (advice-add 'yas-expand :before 'sp-remove-active-pair-overlay))
|
||||
)
|
||||
|
||||
(use-package help-fns+ ; Improved help commands
|
||||
:commands (describe-buffer describe-command describe-file
|
||||
describe-keymap describe-option describe-option-of-type))
|
||||
|
||||
(use-package guide-key
|
||||
:config
|
||||
(setq guide-key/guide-key-sequence '("," "\\")
|
||||
guide-key/recursive-key-sequence-flag t
|
||||
guide-key/popup-window-position 'bottom)
|
||||
(guide-key-mode 1)) ; Enable guide-key-mode
|
||||
|
||||
(provide 'core-editor)
|
||||
;;; core-editor.el ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue