summary refs log tree commit diff stats
path: root/init.el
blob: 688995784a5f605f87f3a141b1a64721610e434c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
;;; emacs init --- an init for emacs  -*- lexical-binding: t; -*-
;; by C. Duckworth <acdw@acdw.net>
;; URL: https://git.acdw.net/emacs
;; Bankruptcy: 9
;;
;; Everyone is permitted to do whatever they like with this software
;; without limitation.  This software comes without any warranty
;; whatsoever, but with two pieces of advice:
;; - Be kind to yourself.
;; - Make good choices.

(yoke +emacs (locate-user-emacs-file "lisp/")
  (require '+emacs)
  ;; Settings
  (setq truncate-string-ellipsis "…"
	ring-bell-function #'ignore
	read-file-name-completion-ignore-case t)
  ;; Keys
  (define-keys (current-global-map)
    "C-x C-k" #'kill-current-buffer
    "C-/" #'undo-only
    "C-?" #'undo-redo
    "C-x C-c" #'+save-buffers-quit
    "M-SPC" #'+cycle-spacing
    "M-/" #'hippie-expand
    "M-=" #'count-words
    "C-x C-b" #'ibuffer
"C-x 4 n" #'clone-buffer
    "S-<down-mouse-1>" #'mouse-set-mark
    "C-x 0" #'+delete-window-or-bury-buffer
    "M-j" nil
    "<Scroll_Lock>" nil)
  ;; Hooks
  (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
  (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
  (add-hook 'find-file-not-found-functions #'+auto-create-missing-dirs)
  ;; Advice
  (add-function :after after-focus-change-function #'+save-some-buffers-debounce)
  (advice-add 'keyboard-escape-quit :around #'keyboard-escape-quit-keep-window-open)
  (define-advice keyboard-escape-quit (:around (fn &rest r))
    "Don't close quits on `keyboard-escape-quit'."
    (let ((buffer-quit-function #'ignore))
      (apply fn r)))
  ;; Themes
  (load-theme 'modus-operandi))

(yoke isearch nil
  (define-keys (current-global-map)
    "C-s" #'isearch-forward-regexp
    "C-r" #'isearch-backward-regexp
    "C-M-s" #'isearch-forward
    "C-M-r" #'isearch-backward))

(yoke auth-source nil
  (setq auth-sources `(default "secrets:passwords"))
  (setq-local-hook authinfo-mode-hook
    truncate-lines t))

(yoke consult "https://github.com/minad/consult"
  (require 'consult)
  (setq register-preview-delay 0
        register-preview-function #'consult-register-format
        xref-show-xrefs-function #'consult-xref
        tab-always-indent 'complete
        completion-in-region-function #'consult-completion-in-region
        consult-narrow-key "<"
        consult--regexp-compiler #'consult--orderless-regexp-compiler)
  (advice-add #'register-preview :override #'consult-register-window)
  (define-keys (current-global-map)
    ;; C-c bindings (mode-specific-map)
    "C-c h" #'consult-history
    "C-c m" #'consult-mode-command
    "C-c b" #'consult-bookmark
    "C-c k" #'consult-kmacro
    ;; C-x bindings (ctl-x-map)
    "C-x M-:" #'consult-complex-command
    "C-x b" #'consult-buffer
    "C-x 4 b" #'consult-buffer-other-window
    "C-x 5 b" #'consult-buffer-other-frame
    ;; Custom M-# bindings for fast register access
    "M-#" #'consult-register-load
    "M-'" #'consult-register-store
    "C-M-#" #'consult-register
    ;; Other custom bindings
    "M-y" #'consult-yank-pop
    ;;("<f1> a" . consult-apropos)
    ;; M-g bindings (goto-map)
    "M-g e" #'consult-compile-error
    "M-g f" #'consult-flymake ; or consult-flycheck
    "M-g g" #'consult-goto-line
    "M-g M-g" #'consult-goto-line
    "M-g o" #'consult-outline ; or consult-org-heading
    "M-g m" #'consult-mark
    "M-g k" #'consult-global-mark
    "M-g i" #'consult-imenu
    "M-g M-i" #'consult-imenu
    "M-g I" #'consult-imenu-multi
    ;; M-s bindings (search-map)
    "M-s f" #'consult-find
    "M-s F" #'consult-locate
    "M-s g" #'consult-grep
    "M-s G" #'consult-git-grep
    "M-s r" #'consult-ripgrep
    "M-s l" #'consult-line
    "M-s L" #'consult-line-multi
    "M-s m" #'consult-multi-occur
    "M-s k" #'consult-keep-lines
    "M-s u" #'consult-focus-lines
    ;; Isearch integration
    "M-s e" #'consult-isearch-history)
  (eval-after isearch-mode
    (define-keys isearch-mode-map
      "M-e" #'consult-isearch-history
      "M-s e" #'consult-isearch-history
      "M-s l" #'consult-line
      "M-s L" #'consult-line-multi))
  (eval-after org
    (define-key org-mode-map (kbd "M-g o") #'consult-org-heading)))

(yoke orderless "https://github.com/oantolin/orderless"
(require 'orderless)
  (setq completion-styles '(substring orderless basic)
        completion-category-defaults nil
        completion-category-overrides '((file (styles basic partial-completion)))
        orderless-component-separator #'orderless-escapable-split-on-space))

(yoke vertico "https://github.com/minad/vertico"
  (require 'vertico)
  (setq resize-mini-windows 'grow-only
        vertico-count-format nil
        vertico-cycle t)
  (vertico-mode))

(yoke marginalia "https://github.com/minad/marginalia/"
  (marginalia-mode))

(yoke slime "https://github.com/slime/slime"
  ;; r7rs-swank
  (let ((r7rsloc (yoke-git "https://github.com/ecraven/r7rs-swank")))
    (cond
     ((executable-find "chibi-scheme")
      (defun chibi-scheme-start-swank (file encoding)
	(format "%S\n\n" `(start-swank ,file)))
      (setq slime-lisp-implementations
	    (cons `(chibi-scheme
		    ("chibi-scheme" ,(format "-A%s" r7rsloc)
		     "-m" "(chibi-swank)")
		    :init chibi-scheme-start-swank)
		  (bound-and-true-p slime-lisp-implementations)))))))

(yoke puni "https://github.com/amaikinono/puni"
  (puni-global-mode)
  (electric-pair-mode)
  (define-keys puni-mode-map
    "C-)" #'puni-slurp-forward
    "C-(" #'puni-slurp-backward
    "C-}" #'puni-barf-forward
    "C-{" #'puni-barf-backward))

(yoke hungry-delete "https://github.com/nflath/hungry-delete"
  (setq hungry-delete-chars-to-skip " \t"
	hungry-delete-join-reluctantly nil)
  (eval-after hungry-delete
    (add-to-list* 'hungry-delete-except-modes
		  'eshell-mode
		  'nim-mode
		  'python-mode))
  (defun +hungry-delete-or (hd-fn fn arg)
    (funcall (if (looking-back (format "[%s]" hungry-delete-chars-to-skip) arg)
		 hd-fn
	       fn)
	     arg))
  (define-keys puni-mode-map
    [remap puni-backward-delete-char]
    (defun puni@hungry-delete-backward (arg)
      (interactive "p")
      (+hungry-delete-or #'hungry-delete-backward
			 #'puni-backward-delete-char
			 arg))
    [remap puni-forward-delete-char]
    (defun puni@hungry-delete-forward (arg)
      (interactive "p")
      (+hungry-delete-or #'hungry-delete-forward
			 #'puni-forward-delete-char
			 arg)))
  (global-hungry-delete-mode))

(yoke cape "https://github.com/minad/cape"
  (defun cape-insinuate ()
    (add-to-list* 'completion-at-point-functions
		  #'cape-dabbrev
		  #'cape-file))
  (add-hook* '(text-mode-hook prog-mode-hook)
	     #'cape-insinuate))

(yoke minions "https://github.com/tarsius/minions"
  (minions-mode))

(yoke magit "https://github.com/magit/magit"
  :load (locate-user-emacs-file "yoke/magit/lisp")
  :depends ((transient "https://github.com/magit/transient"
                       (locate-user-emacs-file "yoke/transient/lisp"))
            (dash "https://github.com/magnars/dash.el")
            (with-editor "https://github.com/magit/with-editor"
                         (locate-user-emacs-file "yoke/with-editor/lisp")))
  (autoload #'transient--with-suspended-override "transient"))