-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
342 lines (258 loc) · 7.64 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
;; -*- lexical-binding: t -*-
(eval-when-compile
(require 'use-package))
(use-package bind-key)
;; Platform specific stuff
(setq mac-right-option-modifier 'none)
;; Put backups in a central directory
(setq backup-directory (expand-file-name "backup" user-emacs-directory))
(use-package files
:config
(setq backup-directory-alist (list (cons "." backup-directory))))
;; Appearance
;; Set font if you wish
;; (let ((font "Source Code Pro"))
;; (when (member font (font-family-list))
;; (set-face-attribute 'default nil :family font)))
(setq inhibit-startup-screen t
visible-bell t
initial-scratch-message nil)
(use-package solarized-dark-theme
:config
(load-theme 'solarized-dark t))
(use-package hl-line
:config
(global-hl-line-mode))
;; Highlighting whitespace
(use-package whitespace
:custom-face
(whitespace-tab ((t (
:inverse-video nil
:foreground nil
:background nil
:inherit 'highlight))))
:config
(setq whitespace-style '(face trailing empty tabs))
(global-whitespace-mode)
(use-package magit
:defer t
:config
(defun jk/prevent-whitespace-mode-for-magit ()
(not (derived-mode-p #'magit-mode)))
(advice-add #'whitespace-enable-predicate :before-while
#'jk/prevent-whitespace-mode-for-magit)))
;; Long lines
;; 80 columns indicator
(use-package fill-column-indicator
:hook ((after-change-major-mode window-configuration-change) . auto-fci-mode)
:config
(defun auto-fci-mode ()
(if (> (window-width) (or fci-rule-column fill-column))
(fci-mode 1)
(fci-mode 0)))
(add-hook 'after-change-major-mode-hook #'auto-fci-mode)
(add-hook 'window-configuration-change-hook #'auto-fci-mode)
;; Wrapping
(setq fci-handle-truncate-lines nil
truncate-partial-width-windows nil))
;; Magit
(use-package magit
:bind ([?\C-c ?g] . #'magit-status)
:config
(setq magit-last-seen-setup-instructions "1.4.0"))
;; ido
(use-package ido
:config
(ido-mode)
(ido-everywhere)
(use-package magit-extras
:bind (:map ido-common-completion-map
([?\C-x ?g] . #'ido-enter-magit-status)))
(use-package magit-base
:after magit
:config
(setq magit-completing-read-function #'magit-ido-completing-read))
(use-package ido-vertical-mode
:config
(ido-vertical-mode))
(use-package ido-completing-read+
:config
(ido-ubiquitous-mode)))
;; Evil
(use-package evil
:init
(setq evil-want-keybinding nil)
(use-package undo-tree
:after files
:config
(setq undo-tree-history-directory-alist backup-directory-alist)
(global-undo-tree-mode))
:custom
(evil-undo-system 'undo-tree)
:config
(evil-mode)
(use-package evil-surround
:config
(global-evil-surround-mode))
(use-package evil-collection
:config
(evil-collection-init))
(use-package evil-search
:config
(evil-select-search-module 'evil-search-module 'evil-search))
;; Ace integration
(use-package evil-integration
:config
(use-package ace-jump-mode)
:bind
(:map evil-motion-state-map
([?g ? ] . #'evil-ace-jump-char-mode)
([?g ? ] . #'evil-ace-jump-char-to-mode)
([?g ?b] . #'evil-ace-jump-word-mode)
([?g return] . #'evil-ace-jump-line-mode)))
(use-package evil-org
:after org
:hook (org-mode . evil-org-mode)
:config
(evil-org-set-key-theme '(navigation insert textobjects additional calendar))
(use-package evil-org-agenda
:config
(evil-org-agenda-set-keys))))
;; Remember cursor position accross sessions
(use-package saveplace
:config
(setq save-place-file (expand-file-name "save-place" user-emacs-directory))
(save-place-mode))
;; Automatically reload changed files from disk
(use-package autorevert
:config
(global-auto-revert-mode))
;; Org
(use-package org
:mode ("\\.org\\'" . org-mode)
:bind (([?\C-c ?l] . #'org-store-link)
([?\C-c ?a] . #'org-agenda)
([?\C-c ?c] . #'org-capture))
:config
(use-package org-inlinetask)
;; TODO Why is this even necessary?
(setcdr (assq 'system org-file-apps-gnu)
(lambda (file &rest _)
(call-process "xdg-open" nil 0 nil file)))
;; TODO This seems like kind of a hack;
;; shouldn't we just remove "pdf" from the `auto-mode-alist`?
(add-to-list 'org-file-apps '("pdf" . system))
(add-to-list 'org-file-apps '("ods" . system))
(org-babel-do-load-languages 'org-babel-load-languages
'((shell . t)
(latex . t)
(python . t)))
;; Make (inline) code use a monospaced font
(set-face-attribute 'org-code nil :family "Monospace")
;; Use IDs for linking if they are there
(setq org-id-link-to-org-use-id 'use-existing
;; Indentation
org-startup-indented t
;; Highlighting in code blocks
org-src-fontify-natively t
;; Configure refile
org-refile-use-outline-path 'file
org-outline-path-complete-in-steps nil
org-refile-targets '((nil . (:maxlevel . 65535))) ; TODO This is a hack ...
org-capture-templates '(("a" "Autofocus" entry (file "~/Sync/org/dump.org") "* %?"))
org-agenda-todo-ignore-scheduled 'future
;; Work around a bug between evil and org
;; See https://github.com/emacs-evil/evil/issues/1630
org-fold-core-style 'overlays)
(use-package evil
:defer t
:config
(add-hook 'org-capture-mode-hook 'evil-insert-state))
(advice-add #'org-latex-preview :before
(lambda (&rest _)
(setq org-format-latex-options
(plist-put org-format-latex-options
:scale (/ (jk/get-font-size) jk/original-font-size))))))
;; Programming
(use-package prog-mode
:defer t
:config
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
(use-package highlight-indent-guides
:hook (prog-mode . highlight-indent-guides-mode)
:config
(setq highlight-indent-guides-method 'character))
(defun jk/no-tabs ()
(setq indent-tabs-mode nil)))
;; Rust
(use-package rust-mode
:mode "\\.rs\\'"
:config
(use-package lsp-mode
:hook rust-mode
:config
(setq lsp-rust-server 'rust-analyzer))
(add-hook 'rust-mode-hook #'jk/no-tabs)
(use-package cargo
:hook (rust-mode . cargo-minor-mode)))
;; Ruby
(use-package ruby-mode
:mode "\\.rb\\'"
:config
(add-hook 'ruby-mode-hook #'jk/no-tabs))
;; Lisp
(use-package elisp-mode
:mode ("\\.el\\'" . emacs-lisp-mode)
:config
(use-package paredit
:hook (emacs-lisp-mode . enable-paredit-mode)))
;; JavaScript & Co.
(use-package js2-mode
:mode "\\.m?jsx?\\'"
:config
(advice-add #'js2-identifier-start-p
:after-until
(lambda (c) (eq c ?#))))
(use-package typescript-mode
:mode "\\.tsx?\\'")
(use-package json-mode
:mode "\\.json\\'"
:config
;; Special settings for `package.json` to appease `npm install --save`
(defun jk/package-json-hook ()
(when (string= (file-name-nondirectory buffer-file-name) "package.json")
(setq indent-tabs-mode nil)
(set (make-local-variable 'js-indent-level) 2)))
(add-hook 'json-mode-hook #'jk/package-json-hook))
;; LaTeX
(use-package perl-mode
:mode "/.?latexmkrc\\'")
;; File types
(use-package cask-mode
:mode "/Cask\\'")
(use-package dockerfile-mode
:mode "/Dockerfile\\'")
(use-package yaml-mode
:mode "\\.ya?ml\\'")
(use-package ledger-mode
:mode "\\.ledger\\'")
(use-package beancount
:mode ("\\.beancount\\'" . beancount-mode))
(use-package markdown-mode
:mode "\\.md\\'")
(use-package glsl-mode
:mode "\\.glsl\\'")
(use-package graphql-mode
:mode "\\.graphql\\'")
(use-package zig-mode
:mode "\\.zig\\'")
(use-package clojure-mode
:mode "\\.clj[sc]?\\'")
(use-package nix-mode
:mode "\\.nix\\'")
;; Load Customizations
;; Customize
(setq custom-file (expand-file-name "customize.el" user-emacs-directory))
(when (file-readable-p custom-file)
(load custom-file))