blob: d48c93e61a5c3faea1076865f53203e81459e88a (
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
|
;; Path Configuration
(setq abbrev-file-name (my/cache-file-name "abbrev-def")
auto-save-list-file-prefix (my/cache-file-name "auto-save/")
backup-directory-alist `(("." . ,(my/cache-file-name "backups")))
custom-file (my/cache-file-name "custom.el")
transient-history-file (my/cache-file-name "transient/history.el"))
;; General Configuration
(setq-default indent-tabs-mode nil
fill-column 72)
(setq backup-by-copying t
confirm-kill-emacs #'y-or-n-p
display-time-24hr-format t
inhibit-startup-screen t
recenter-positions '(3 middle top bottom)
require-final-newline t
ring-bell-function #'ignore
sentence-end-double-space nil
show-paren-delay 0
uniquify-buffer-name-style 'post-forward-angle-brackets
vc-follow-symlinks nil)
(add-to-list 'completion-styles 'flex)
(put 'list-timers 'disabled nil)
(add-hook 'after-init-hook #'my/display-startup-time)
(add-hook 'before-save-hook #'delete-trailing-whitespace)
(auto-save-mode -1)
(auto-save-visited-mode 1)
(blink-cursor-mode -1)
(column-number-mode 1)
(display-time-mode (if (getenv "TMUX") -1 1))
(electric-indent-mode -1)
(global-auto-revert-mode 1)
(marginalia-mode 1)
(global-set-key (kbd "C-c q") #'electric-quote-local-mode)
;; Buffer Management
(setq ibuffer-saved-filter-groups
'(("default"
("Emacs" (or (mode . completion-list-mode)
(mode . debugger-mode)
(mode . help-mode)
(mode . messages-buffer-mode)
(name . "^\\*scratch\\*$")))
("Magit" (name . "^magit"))
("Dired" (mode . dired-mode))
("Shells" (mode . term-mode))
("Manuals" (or (mode . Info-mode)
(mode . Man-mode)))))
ibuffer-show-empty-filter-groups nil)
(my/with-add-hook 'ibuffer-mode-hook
(ibuffer-switch-to-saved-filter-groups "default"))
(global-set-key (kbd "C-x b") #'consult-buffer)
(global-set-key (kbd "C-x C-b") #'ibuffer)
;; Search and Completion Management
(vertico-mode 1)
(setq completion-ignore-case t
completion-in-region-function #'consult-completion-in-region)
(global-set-key (kbd "C-c s") #'consult-ripgrep)
(dolist (fn '(isearch-forward isearch-backward))
(advice-add fn :after #'my/isearch-region))
;; Theme Management
(defvar my/day-theme nil "Theme to use during the day.")
(defvar my/night-theme nil "Theme to use during the night.")
;; “Window” Management
(global-set-key (kbd "<C-tab>") #'other-window)
(global-set-key (kbd "<C-M-tab>") #'other-frame)
(global-set-key (kbd "C-c l") #'my/focus-frame)
(global-set-key (kbd "C-c f") #'toggle-frame-maximized)
(windmove-default-keybindings 'super)
(dolist (fn '(delete-window split-window-horizontally split-window-vertically))
(advice-add fn :after #'(lambda (&rest _args) (balance-windows))))
(advice-add #'fill-paragraph :around
#'(lambda (orig &rest args)
(let* ((offset (save-excursion
(back-to-indentation)
(current-column)))
(fill-column (+ offset fill-column)))
(apply orig args))))
(if (daemonp) (add-hook 'before-make-frame-hook #'my/disable-frame-modes)
(my/disable-frame-modes))
;; Bazel
(setq bazel-buildifier-before-save t)
;; C++
(setq clang-format-style "google")
(my/with-add-hook 'c-initialization-hook
(local-set-key (kbd "C-c d") #'clang-format))
(add-hook 'c-mode-common-hook #'google-set-c-style)
(add-hook 'c++-mode-hook #'flycheck-mode)
;; Dired
(put 'dired-find-alternate-file 'disabled nil)
(my/with-add-hook 'dired-mode-hook
(setq-local mouse-1-click-follows-link (- mouse-1-click-follows-link))
(local-set-key [mouse-1] #'dired-find-file))
;; Go
(when (executable-find "goimports")
(setq gofmt-args '("-local" "go.awhk.org")
gofmt-command "goimports"))
(my/with-add-hook 'go-mode-hook
(setq-local auto-save-visited-mode nil)
(setq tab-width 2)
(when (executable-find "gopls")
(eglot-ensure)
(add-hook 'before-save-hook #'my/eglot-organize-imports nil :local)
(add-hook 'before-save-hook #'eglot-format-buffer nil :local)))
;; Flycheck
(setq flycheck-clang-language-standard "c++20")
;; Git
(setq git-commit-summary-max-length 50)
(add-hook 'git-commit-setup-hook #'electric-quote-local-mode)
(add-hook 'git-commit-setup-hook #'git-commit-turn-on-flyspell)
(global-set-key (kbd "C-c k") #'magit-status)
;; Org
(setq org-startup-folded "showall")
;; Shell Scripts
(setq sh-basic-offset 2)
(push '("/PKGBUILD\\'" . sh-mode) auto-mode-alist)
(push '("#compdef .+" . sh-mode) magic-mode-alist)
;; systemd
(dolist (regexp '("\\.service\\'" "\\.socket\\'" "\\.timer\\'"))
(push `(,regexp . conf-mode) auto-mode-alist))
;; Further Customization
(my/load-file-variations "emacs/init")
|