2018-02-14 23:16:38 -05:00
|
|
|
;;; config/default/config.el -*- lexical-binding: t; -*-
|
2017-12-23 02:27:42 -05:00
|
|
|
|
2018-05-27 12:44:22 +02:00
|
|
|
(if (featurep! +bindings) (load! "+bindings"))
|
2017-12-30 00:56:54 -05:00
|
|
|
|
|
|
|
|
2017-12-27 22:48:05 -05:00
|
|
|
;;
|
2018-09-07 19:36:16 -04:00
|
|
|
;; Packages
|
2017-12-27 22:48:05 -05:00
|
|
|
|
2018-01-30 21:24:18 -05:00
|
|
|
(def-package! emacs-snippets
|
|
|
|
:if (featurep! +snippets)
|
2018-05-08 01:00:49 +02:00
|
|
|
:after yasnippet)
|
2017-12-23 02:27:42 -05:00
|
|
|
|
|
|
|
|
2017-12-27 22:48:05 -05:00
|
|
|
;;
|
|
|
|
;; Config
|
|
|
|
|
2018-09-18 17:41:25 -04:00
|
|
|
;; Don't store authinfo in plain text!
|
2018-06-01 17:10:30 +02:00
|
|
|
(defvar auth-sources
|
|
|
|
(list (expand-file-name "authinfo.gpg" doom-etc-dir)
|
|
|
|
"~/.authinfo.gpg"))
|
|
|
|
|
2017-12-27 22:48:05 -05:00
|
|
|
(after! epa
|
|
|
|
(setq epa-file-encrypt-to (or epa-file-encrypt-to user-mail-address)
|
|
|
|
;; With GPG 2.1, this forces gpg-agent to use the Emacs minibuffer to
|
|
|
|
;; prompt for the key passphrase.
|
|
|
|
epa-pinentry-mode 'loopback))
|
|
|
|
|
|
|
|
|
2018-02-14 05:10:48 -05:00
|
|
|
;; disable :unless predicates with (sp-pair "'" nil :unless nil)
|
|
|
|
;; disable :post-handlers with (sp-pair "{" nil :post-handlers nil)
|
|
|
|
;; ...or specific :post-handlers with (sp-pair "{" nil :post-handlers '(:rem ("| " "SPC")))
|
|
|
|
(after! smartparens
|
|
|
|
;; Autopair quotes more conservatively; if I'm next to a word/before another
|
|
|
|
;; quote, I likely don't want another pair.
|
|
|
|
(let ((unless-list '(sp-point-before-word-p
|
|
|
|
sp-point-after-word-p
|
|
|
|
sp-point-before-same-p)))
|
|
|
|
(sp-pair "'" nil :unless unless-list)
|
|
|
|
(sp-pair "\"" nil :unless unless-list))
|
|
|
|
|
2018-05-25 00:46:11 +02:00
|
|
|
;; Major-mode specific fixes
|
2018-07-06 15:28:55 +02:00
|
|
|
(sp-local-pair '(ruby-mode enh-ruby-mode) "{" "}"
|
2018-07-07 00:32:45 +02:00
|
|
|
:pre-handlers '(:rem sp-ruby-pre-handler)
|
|
|
|
:post-handlers '(:rem sp-ruby-post-handler))
|
2018-05-25 00:46:11 +02:00
|
|
|
|
2018-02-14 05:10:48 -05:00
|
|
|
;; Expand {|} => { | }
|
|
|
|
;; Expand {|} => {
|
|
|
|
;; |
|
|
|
|
;; }
|
|
|
|
(dolist (brace '("(" "{" "["))
|
|
|
|
(sp-pair brace nil
|
|
|
|
:post-handlers '(("||\n[i]" "RET") ("| " "SPC"))
|
|
|
|
;; I likely don't want a new pair if adjacent to a word or opening brace
|
|
|
|
:unless '(sp-point-before-word-p sp-point-before-same-p)))
|
|
|
|
|
|
|
|
;; Don't do square-bracket space-expansion where it doesn't make sense to
|
|
|
|
(sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode)
|
|
|
|
"[" nil :post-handlers '(:rem ("| " "SPC")))
|
|
|
|
|
2018-06-25 15:54:38 +02:00
|
|
|
;; 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]" "*")))
|
|
|
|
|
2018-02-14 05:10:48 -05:00
|
|
|
;; Highjacks backspace to:
|
|
|
|
;; a) balance spaces inside brackets/parentheses ( | ) -> (|)
|
|
|
|
;; b) delete space-indented `tab-width' steps at a time
|
|
|
|
;; c) close empty multiline brace blocks in one step:
|
|
|
|
;; {
|
|
|
|
;; |
|
|
|
|
;; }
|
|
|
|
;; becomes {|}
|
|
|
|
;; d) refresh smartparens' :post-handlers, so SPC and RET expansions work
|
|
|
|
;; even after a backspace.
|
|
|
|
;; e) properly delete smartparen pairs when they are encountered, without the
|
|
|
|
;; need for strict mode.
|
|
|
|
;; f) do none of this when inside a string
|
|
|
|
(advice-add #'delete-backward-char :override #'doom/delete-backward-char)
|
|
|
|
|
|
|
|
;; Makes `newline-and-indent' smarter when dealing with comments
|
2018-09-14 10:42:09 -04:00
|
|
|
(advice-add #'newline-and-indent :around #'doom*newline-indent-and-continue-comments))
|
2018-02-14 05:10:48 -05:00
|
|
|
|
|
|
|
|
2017-12-23 02:27:42 -05:00
|
|
|
(when (featurep 'evil)
|
2018-01-30 21:24:18 -05:00
|
|
|
(when (featurep! +evil-commands)
|
2018-05-27 12:44:22 +02:00
|
|
|
(load! "+evil-commands"))
|
2017-12-30 00:56:54 -05:00
|
|
|
|
2018-01-30 21:24:18 -05:00
|
|
|
(when (featurep! +bindings)
|
2018-03-25 22:39:03 -04:00
|
|
|
(defvar +default-repeat-forward-key ";")
|
|
|
|
(defvar +default-repeat-backward-key ",")
|
|
|
|
|
2018-05-15 03:24:30 +02:00
|
|
|
(eval-when-compile
|
2018-05-14 20:35:26 +02:00
|
|
|
(defmacro do-repeat! (command next-func prev-func)
|
2018-05-15 03:24:30 +02:00
|
|
|
"Makes ; and , the universal repeat-keys in evil-mode. These keys can be
|
|
|
|
customized by changing `+default-repeat-forward-key' and
|
|
|
|
`+default-repeat-backward-key'."
|
2018-05-14 20:35:26 +02:00
|
|
|
(let ((fn-sym (intern (format "+evil*repeat-%s" (doom-unquote command)))))
|
|
|
|
`(progn
|
|
|
|
(defun ,fn-sym (&rest _)
|
2018-06-07 02:49:32 +02:00
|
|
|
(define-key! evil-motion-state-map
|
|
|
|
+default-repeat-forward-key #',next-func
|
|
|
|
+default-repeat-backward-key #',prev-func))
|
2018-05-14 20:35:26 +02:00
|
|
|
(advice-add #',command :before #',fn-sym)))))
|
2017-12-30 00:56:54 -05:00
|
|
|
|
2018-01-30 21:24:18 -05:00
|
|
|
;; n/N
|
|
|
|
(do-repeat! evil-ex-search-next evil-ex-search-next evil-ex-search-previous)
|
|
|
|
(do-repeat! evil-ex-search-previous evil-ex-search-next evil-ex-search-previous)
|
|
|
|
(do-repeat! evil-ex-search-forward evil-ex-search-next evil-ex-search-previous)
|
|
|
|
(do-repeat! evil-ex-search-backward evil-ex-search-next evil-ex-search-previous)
|
2017-12-30 00:56:54 -05:00
|
|
|
|
2018-01-30 21:24:18 -05:00
|
|
|
;; f/F/t/T/s/S
|
2018-03-20 15:56:52 -04:00
|
|
|
(setq evil-snipe-repeat-keys nil
|
|
|
|
evil-snipe-override-evil-repeat-keys nil) ; causes problems with remapped ;
|
2018-05-14 20:42:48 +02:00
|
|
|
(do-repeat! evil-snipe-f evil-snipe-repeat evil-snipe-repeat-reverse)
|
|
|
|
(do-repeat! evil-snipe-F evil-snipe-repeat evil-snipe-repeat-reverse)
|
|
|
|
(do-repeat! evil-snipe-t evil-snipe-repeat evil-snipe-repeat-reverse)
|
|
|
|
(do-repeat! evil-snipe-T evil-snipe-repeat evil-snipe-repeat-reverse)
|
|
|
|
(do-repeat! evil-snipe-s evil-snipe-repeat evil-snipe-repeat-reverse)
|
|
|
|
(do-repeat! evil-snipe-S evil-snipe-repeat evil-snipe-repeat-reverse)
|
|
|
|
(do-repeat! evil-snipe-x evil-snipe-repeat evil-snipe-repeat-reverse)
|
|
|
|
(do-repeat! evil-snipe-X evil-snipe-repeat evil-snipe-repeat-reverse)
|
2017-12-30 00:56:54 -05:00
|
|
|
|
2018-01-30 21:24:18 -05:00
|
|
|
;; */#
|
2018-05-14 20:42:48 +02:00
|
|
|
(do-repeat! evil-visualstar/begin-search-forward
|
|
|
|
evil-ex-search-next evil-ex-search-previous)
|
|
|
|
(do-repeat! evil-visualstar/begin-search-backward
|
|
|
|
evil-ex-search-previous evil-ex-search-next)))
|