-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
406 lines (336 loc) · 12 KB
/
init.el
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
;;; init.el --- Emacs initialization file -*- lexical-binding: t -*-
;; Copyright (C) 2021 Eric Haberstroh
;; Maintainer: [email protected]
;; Keywords: startup init
;; Package: eh-emacs
;; This file is NOT part of GNU Emacs.
;; This file is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this file. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This file configures Emacs.
;;; Code:
(setq inhibit-startup-message t)
(scroll-bar-mode -1) ;; Disable visible scrollbar
(tool-bar-mode -1) ;; Disable the toolbar
(tooltip-mode -1) ;; Disable tooltips
(menu-bar-mode -1) ;; Disable the menu bar
(set-fringe-mode 10) ;; Give some breathing room
;; Set up the visible bell
(setq visible-bell t)
;; Use a better-looking font
(set-face-attribute 'default nil :font "Fira Code Retina" :height 120)
;; White background blinds me
(load-theme 'tango-dark t)
;; Make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; Don't put customizations in this file
(setq custom-file (concat user-emacs-directory "custom.el"))
(when (file-exists-p custom-file)
(load custom-file))
;; Initialize package sources
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("elpa" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
;; Initialize use-package
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
;; Load my favorite theme
(use-package doom-themes
:init (load-theme 'doom-dracula t))
;; Show column numbers in the modeline
(column-number-mode 1)
;; Show line numbers...
(global-display-line-numbers-mode 1)
;; ... but not in some major modes
(dolist (mode '(org-mode-hook
term-mode-hook
eshell-mode-hook
shell-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode -1))))
;; Configure searching
(use-package swiper)
;; Alternatives to some built-in commands
(use-package counsel
:bind (("M-x" . counsel-M-x)
("C-x b" . counsel-ibuffer)
("C-x C-f" . counsel-find-file)
:map minibuffer-local-map
("C-r" . counsel-minibuffer-history)))
(use-package ivy
:diminish
:bind (("C-s" . swiper)
:map ivy-minibuffer-map
("TAB" . ivy-alt-done)
("C-l" . ivy-alt-done)
("C-j" . ivy-next-line)
("C-k" . ivy-previous-line)
:map ivy-switch-buffer-map
("C-k" . ivy-previous-line)
("C-l" . ivy-done)
("C-d" . ivy-switch-buffer-kill)
:map ivy-reverse-i-search-map
("C-k" . ivy-previous-line)
("C-d" . ivy-reverse-i-search-kill))
:config
(ivy-mode 1))
(global-set-key (kbd "C-M-j") 'counsel-switch-buffer)
;; Make Ivy displays more helpful
(use-package ivy-rich
:init (ivy-rich-mode 1))
;; More helpful help functions
(use-package helpful
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable)
:bind
([remap describe-function] . counsel-describe-function)
([remap describe-command] . helpful-command)
([remap describe-variable] . counsel-describe-variable)
([remap describe-key] . helpful-key))
;; Configure the modeline
(use-package doom-modeline
:init (doom-modeline-mode 1)
:custom ((doom-modeline-height 30)))
;; More colorful parentheses
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
;; Show which keybindings are available
(use-package which-key
:init (which-key-mode)
:custom ((which-key-idle-delay 0.3)))
;; Pretty icons
(use-package all-the-icons
:if (display-graphic-p)
:commands all-the-icons-install-fonts
:init
(unless (find-font (font-spec :name "all-the-icons"))
(all-the-icons-install-fonts t)))
(use-package all-the-icons-dired
:if (display-graphic-p)
:hook (dired-mode . all-the-icons-dired-mode))
;; More convenient keybindings
(use-package general
:config
(general-create-definer ehmacs/leader-keys
:keymaps '(normal insert visual emacs)
:prefix "SPC"
:global-prefix "C-SPC")
(ehmacs/leader-keys
"t" '(:ignore t :which-key "toggles")
"tt" '(counsel-load-theme :which-key "choose theme")))
(defun ehmacs/evil-hook ()
"Setup evil mode"
(dolist (mode '(custom-mode
eshell-mode
git-rebase-mode
erc-mode
circe-server-mode
circe-chat-mode
circe-query-mode
sauron-mode
term-mode))
(add-to-list 'evil-emacs-state-modes mode)))
;; Become evil
(setq org-want-keybinding nil)
(use-package evil
:custom
(evil-want-integration t)
(evil-want-C-u-scroll t)
(evil-want-C-i-jump nil)
:hook (evil-mode . ehmacs/evil-hook)
:init
(evil-mode 1)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
;; Use visual line motions even outside of visual-line-mode buffers
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
(evil-set-initial-state 'messages-buffer-mode 'normal)
(evil-set-initial-state 'dashboard-mode 'normal))
(use-package evil-collection
:after evil
:config
(evil-collection-init))
;; Many heads
(use-package hydra)
(defhydra hydra-text-scale (:timeout 4)
"scale text"
("j" text-scale-increase "in")
("k" text-scale-decrease "out")
("f" nil "finished" :exit t))
(ehmacs/leader-keys
"ts" '(hydra-text-scale/body :which-key "scale text"))
(setq auth-sources '("~/.authinfo.gpg"))
;; Project management
(use-package projectile
:config (projectile-mode)
:custom (projectile-completion-system 'ivy)
:bind-keymap
("C-c p" . projectile-command-map)
:init
(when (file-directory-p "~/Code")
(setq projectile-project-search-path '("~/Code")))
(setq projectile-switch-project-action #'projectile-dired))
(use-package counsel-projectile
:config (counsel-projectile-mode 1))
;; Version control
(use-package magit
:commands (magit-status magit-get-current-branch)
:custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
;; For this to work: https://magit.vc/manual/ghub.html#Creating-and-Storing-a-Token
(use-package forge
:after magit)
;; Orgmode
(defun ehmacs/org-mode-setup ()
"Various set up tasks for Orgmode"
(org-indent-mode 1)
(variable-pitch-mode 1)
(auto-fill-mode 0)
(visual-line-mode 1)
(setq evil-auto-indent nil))
(use-package org
:ensure org-plus-contrib
:hook (org-mode . ehmacs/org-mode-setup)
:custom
(org-agenda-files '("~/org"))
(org-todo-keywords
'((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
(sequence "BACKLOG(b)" "PLAN(p)" "READY(r)" "ACTIVE(a)" "REVIEW(v)" "WAIT(w@/!)" "HOLD(h)" "|" "COMPLETED(c)" "CANC(k@)")))
(org-agenda-custom-commands
'(("d" "Dashboard"
((agenda "" ((org-deadline-warning-days 7)))
(todo "NEXT"
((org-agenda-overriding-header "Next Tasks")))
(tags-todo "agenda/ACTIVE" ((org-agenda-overriding-header "Active Projects")))))
("n" "Next Tasks"
((todo "NEXT"
((org-agenda-overriding-header "Next Tasks")))))
("W" "Work Tasks" tags-todo "+work-email")
;; Low-effort next actions
("e" tags-todo "+TODO=\"NEXT\"+Effort<15&+Effort>0"
((org-agenda-overriding-header "Low Effort Tasks")
(org-agenda-max-todos 20)
(org-agenda-files org-agenda-files)))
("w" "Workflow Status"
((todo "WAIT"
((org-agenda-overriding-header "Waiting on External")
(org-agenda-files org-agenda-files)))
(todo "REVIEW"
((org-agenda-overriding-header "In Review")
(org-agenda-files org-agenda-files)))
(todo "PLAN"
((org-agenda-overriding-header "In Planning")
(org-agenda-todo-list-sublevels nil)
(org-agenda-files org-agenda-files)))
(todo "BACKLOG"
((org-agenda-overriding-header "Project Backlog")
(org-agenda-todo-list-sublevels nil)
(org-agenda-files org-agenda-files)))
(todo "READY"
((org-agenda-overriding-header "Ready for Work")
(org-agenda-files org-agenda-files)))
(todo "ACTIVE"
((org-agenda-overriding-header "Active Projects")
(org-agenda-files org-agenda-files)))
(todo "COMPLETED"
((org-agenda-overriding-header "Completed Projects")
(org-agenda-files org-agenda-files)))
(todo "CANC"
((org-agenda-overriding-header "Cancelled Projects")
(org-agenda-files org-agenda-files)))))))
(org-tag-alist
'((:startgroup)
;; Put mutually exclusive tags here
(:endgroup)
("@errand" . ?E)
("@home" . ?H)
("@work" . ?W)
("pvt" . ?t)
("pvg" . ?g)
("pvf" . ?f)
("pkb" . ?b)
("jet" . ?j)))
(org-refile-targets
'(("Archiv.org" :maxlevel . 2)
("Aufgaben.org" :maxlevel . 1)))
(org-capture-templates
'(("t" "Tasks / Projects")
("tt" "Task" entry (file+olp "~/org/Aufgaben.org" "Eingang")
"* TODO %?\n %U\n %a\n %i" :empty-lines 1)
("ts" "Clocked Entry Subtask" entry (clock)
"* TODO %?\n %U\n %a\n %i" :empty-lines 1)
("j" "Journal Entries")
("jj" "Journal" entry
(file+olp+datetree "~/org/Tagebuch.org")
"\n* %<%I:%M %p> - Journal :journal:\n\n%?\n\n"
:clock-in :clock-resume
:empty-lines 1)
("jm" "Meeting" entry
(file+olp+datetree "~/org/Tagebuch.org")
"* %<%I:%M %p> - %a :meetings:\n\n%?\n\n"
:clock-in :clock-resume
:empty-lines 1)
("m" "Metrics Capture")
("mw" "Weight" table-line (file+headline "~/org/Metrik.org" "Gewicht")
"| %U | %^{Weight} | %^{Notizen} |" :kill-buffer t)))
(org-agenda-start-with-log-mode t)
(org-log-done 'time)
(org-log-into-drawer t)
:config
(setq org-ellipsis " ▼"
org-hide-emphasis-markers nil)
;; Save Org buffers after refiling
(advice-add 'org-refile :after 'org-save-all-org-buffers))
(use-package org-bullets
:after org
:hook (org-mode . org-bullets-mode))
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "·"))))))
(with-eval-after-load 'org-faces
(dolist (face '((org-level-1 . 1.2)
(org-level-2 . 1.1)
(org-level-3 . 1.05)
(org-level-4 . 1.0)
(org-level-5 . 1.1)
(org-level-6 . 1.1)
(org-level-7 . 1.1)
(org-level-8 . 1.1)))
(set-face-attribute (car face) nil :font "Cantarell" :weight 'regular :height (cdr face))))
(require 'org-indent)
(with-eval-after-load 'org-faces
(set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-date nil :inherit 'fixed-pitch)
(set-face-attribute 'org-document-info-keyword nil :inherit 'fixed-pitch)
(set-face-attribute 'org-drawer nil :inherit 'fixed-pitch)
(set-face-attribute 'org-indent nil :inherit '(org-hide fixed-pitch))
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-table nil :inherit 'fixed-pitch)
(set-face-attribute 'org-todo nil :inherit 'fixed-pitch)
(set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch)))
(defun ehmacs/org-mode-visual-fill ()
"Set up visual-fill-mode for Orgmode buffers"
(setq visual-fill-column-width 100
visual-fill-column-center-text t)
(visual-fill-column-mode 1))
(use-package visual-fill-column
:defer t
:hook (org-mode . ehmacs/org-mode-visual-fill))
;;; init.el ends here