blob: 061b1f734c79fac06c8d52581b8db8d389391969 (
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
|
;;; td-common.el --- a step up from vanilla -*- lexical-binding: t; -*-
;;; Code:
;;; Functions
(defun td/quit-if-not-in-macro ()
"Allow for an unintentional `C-g' when recording macros."
(interactive)
(if (or defining-kbd-macro executing-kbd-macro)
(progn
(if (region-active-p)
(deactivate-mark)
(message "Macro running. Can't quit.")))
(keyboard-quit)))
(defun td/soft-kill-line ()
"Kill a line while keeping expressions balanced. When there's no complete
sexp before the line end to delete, delete one sexp forward."
(interactive)
(require 'puni)
(puni-soft-delete-by-move (lambda ()
(if (eolp)
(forward-char)
(end-of-line)))
nil 'within 'kill 'delete-one))
;;; Packages
(use-package async
:ensure t
:config
(async-bytecomp-package-mode 1))
(use-package avy
:ensure t
:bind (("M-j" . avy-goto-char-timer))
:custom
(avy-timeout-seconds 0.25))
(use-package consult
:ensure t
:demand t
:bind (("M-s g" . consult-ripgrep)
("M-s f" . consult-find)
("M-s i" . consult-imenu)
("M-s l" . consult-line)
("C-x C-b" . consult-buffer)
:map minibuffer-local-map
("C-r" . consult-history)))
(use-package consult-dir
:ensure t
:bind (("C-x C-d" . consult-dir)
:map vertico-map
("C-x C-d" . consult-dir)
("C-x C-j" . consult-dir-jump-file))
:custom
(consult-dir-project-list-function nil))
(use-package emacs
:ensure nil
:demand t
:bind (("M-c" . capitalize-dwim)
("M-u" . upcase-dwim)
("M-l" . downcase-dwim)
("C-x M-t" . transpose-regions)
("C-g" . td/quit-if-not-in-macro)))
(use-package embark
:ensure t
:bind (("C-." . embark-act)
("M-." . embark-dwim)
("C-h B" . embark-bindings))
:config
;; Remove mixed indicator to prevent popup from being displayed automatically.
(delete #'embark-mixed-indicator embark-indicators)
(add-to-list 'embark-indicators 'embark-minimal-indicator)
;; Use embark to show command prefix help.
(setq prefix-help-command #'embark-prefix-help-command))
(use-package embark-consult
:ensure t
:after embark)
(use-package expand-region
:ensure t
:bind ([remap mark-paragraph] . er/expand-region))
(use-package helpful
:ensure t
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable)
:bind
([remap describe-function] . helpful-function)
([remap describe-command] . helpful-command)
([remap describe-symbol] . helpful-symbol)
([remap describe-variable] . helpful-variable)
([remap describe-key] . helpful-key))
(use-package marginalia
:ensure t
:after vertico
:custom
(marginalia-annotators '(marginalia-annotators-heavy
marginalia-annotators-light
nil))
:config
(marginalia-mode))
(use-package no-littering
:ensure t
:demand t
:config
;; Set custom-file to a file that won't be tracked by git.
(setq custom-file
(let ((custom-file "custom.el"))
(if (boundp 'server-socket-dir)
(expand-file-name custom-file server-socket-dir)
(no-littering-expand-etc-file-name custom-file))))
(when (file-exists-p custom-file)
(load custom-file t))
;; Don't litter project folders with backup files.
(let ((backup-dir (no-littering-expand-var-file-name "backup/")))
(make-directory backup-dir t)
(setq backup-directory-alist
`(("\\`/tmp/" . nil)
("\\`/dev/shm/" . nil)
("." . ,backup-dir))))
;; Tidy up auto-save files.
(setq auto-save-default nil)
(let ((auto-save-dir (no-littering-expand-var-file-name "auto-save/")))
(make-directory auto-save-dir t)
(setq auto-save-file-name-transforms
`(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" ,(concat temporary-file-directory "\\2") t)
("\\`\\(/tmp\\|/dev/shm\\)\\([^/]*/\\)*\\(.*\\)\\'" "\\3")
("." ,auto-save-dir t)))))
(use-package puni
:ensure t
:hook (((eat-mode eshell-mode) . puni-disable-puni-mode)
(prog-mode . puni-mode)
(puni-mode . electric-pair-local-mode))
:bind (:map puni-mode-map
([remap forward-sentence] . puni-beginning-of-sexp)
([remap backward-sentence] . puni-end-of-sexp)
([remap forward-sexp] . puni-forward-sexp-or-up-list)
([remap backward-sexp] . puni-backward-sexp-or-up-list)
([remap kill-line] . puni-kill-line)
([remap mark-paragraph] . puni-expand-region)
("C-)" . puni-slurp-forward)
("C-(" . puni-slurp-backward)
("C-}" . puni-barf-forward)
("C-{" . puni-barf-backward)
("M-(" . puni-wrap-round)
("C-M-t" . puni-transpose)
("C-M-?" . puni-convolute)
("C-M-z" . puni-squeeze)
("C-w" . kill-region)
;; Make puni-kill-line less greedy.
([remap puni-kill-line] . td/soft-kill-line))
:config
(puni-global-mode t))
(use-package savehist
:ensure t
:init
(savehist-mode))
(use-package vertico
:ensure t
:demand t
:bind (:map vertico-map
("C-j" . vertico-next)
("C-k" . vertico-previous)
("C-f" . vertico-exit-input)
:map minibuffer-local-map
("M-h" . vertico-directory-up))
:custom
(vertico-cycle t)
:config
(require 'vertico-directory)
(vertico-mode))
(use-package which-key
:ensure t
:defer 0
:diminish which-key-mode
:config
(setq which-key-idle-delay 0.5)
(which-key-mode))
(provide 'td-common)
;;; td-common.el ends here
|