blob: e1d36cc41edd41083aed104c6c1355aba3764ff1 (
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
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
|
;;; init.el --- Emacs initialization -*- lexical-binding: t -*-
;;; Commentary:
;; Emacs initialization file. Contains my personal and evolving Emacs
;; configuration - what a rabbit hole!
;;; Code:
;;; -- Customizations --
(defcustom init/journal-file "~/Documents/Journal.org"
"The path to my journal file."
:tag "Journal File"
:type '(string)
:group 'convenience)
;;; -- Utility Functions --
(defun init/expand-file-name (name)
"Expands file NAME relative to the `user-emacs-directory'."
(expand-file-name name user-emacs-directory))
(defun init/show-trailing-whitespace ()
"Show trailing whitespace for the current buffer."
(setq-local show-trailing-whitespace t))
(defun init/auto-save-directory ()
"The auto-save directory where the save file lives."
(file-name-directory (concat auto-save-list-file-prefix "1-localhost")))
(defun init/open-init ()
"Opens the Emacs init.el configuration file."
(interactive)
(find-file (init/expand-file-name "init.el")))
(defun init/open-local-init ()
"Opens the system-specific configuration file."
(interactive)
(find-file custom-file))
(defun init/open-journal ()
"Opens my journal."
(interactive)
(find-file init/journal-file))
(defun init/typescript-eglot-settings ()
"Configures buffer-local Eglot settings for TypeScript."
;; The TS language server monitors the parent's proces ID and will
;; automatically kill itself if the process ID is no longer there. Since we
;; run tools in containerized environments, we don't want this behaviour:
;; Emacs is running on the host, and its PID is not visible to the container.
;; Tell Eglot to **not** send a process ID, which disables this feature in
;; the TS language server.
(setq-local eglot-withhold-process-id t))
;;; -- Emacs Configuration --
(use-package emacs
:hook ((before-save . delete-trailing-whitespace)
(prog-mode . display-line-numbers-mode)
(prog-mode . init/show-trailing-whitespace))
:bind (("C-c ," . init/open-local-init)
("C-c C-," . init/open-init)
("C-c C-j" . init/open-journal)
("C-." . completion-at-point)
("C-x k" . kill-current-buffer)
("M-/" . hippie-expand))
:custom
(use-short-answers t)
(inhibit-startup-screen t)
(initial-scratch-message "")
(initial-major-mode 'fundamental-mode)
(frame-title-format '("%b"))
(ring-bell-function 'ignore)
(sentence-end-double-space nil)
(cursor-type 'bar)
(indent-tabs-mode nil)
(tab-width 2)
(backup-by-copying t)
(backup-directory-alist `((".*" . ,(init/expand-file-name "backup"))))
(auto-save-file-name-transforms `((".*" ,(init/auto-save-directory) t)))
(create-lockfiles nil)
(tab-width 4)
(tab-always-indent 'complete)
(completion-styles '(basic initials substring))
(auto-revert-avoid-polling t)
(major-mode-remap-alist
'((c-mode . c-ts-mode)
(javascript-mode . js-ts-mode)
(typescript-mode . typescript-ts-mode)))
(custom-file (init/expand-file-name "local-init.el"))
:init
(menu-bar-mode -1)
(tool-bar-mode -1)
(when (fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
(which-key-mode +1)
(savehist-mode +1)
(column-number-mode +1)
(delete-selection-mode +1)
(global-auto-revert-mode +1)
(load-theme 'modus-vivendi t)
(load (init/expand-file-name "local-init.el") t t)
(setq gc-cons-threshold (or init/gc-cons-threshold 800001)))
;;; -- Built-ins --
(use-package completion-preview
:hook ((prog-mode . completion-preview-mode))
:bind (:map completion-preview-active-mode-map
("M-n" . completion-preview-next-candidate)
("M-p" . completion-preview-prev-candidate)))
(use-package eglot
:bind (:map eglot-mode-map
("M-q" . eglot-format))
:config
(fset #'jsonrpc--log-event #'ignore)
(add-to-list 'eglot-server-programs
'(sol-mode . ("nomicfoundation-solidity-language-server" "--stdio"))))
(use-package project
:custom
(project-mode-line t)
:config
(add-to-list 'project-switch-commands
'(magit-status "Magit" "m") t))
(use-package xref
:config
(when (executable-find "rg")
(setopt xref-search-program 'ripgrep)))
;;; -- Packages --
;; Enable MELPA, but make it a lower priority to GNU and non-GNU ELPA
;; repositories. This makes it so we fallback to MELPA when there are
;; no stable versions on the official ELPA repositories.
(use-package package
:custom
(package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")
("melpa" . "https://melpa.org/packages/")))
(package-archive-priorities '(("gnu" . 1)
("nongnu" . 1)
("melpa" . 0))))
;;; -- Prelude --
(use-package ace-window
:ensure t
:bind (("C-x o" . ace-window)))
(use-package avy
:ensure t
:bind (("C-:" . avy-goto-char)
("C-'" . avy-goto-char-timer)
("M-g f" . avy-goto-line)))
(use-package corfu
:ensure t
:hook ((prog-mode . corfu-mode)
(corfu-mode . corfu-popupinfo-mode))
:bind (:map corfu-map
("SPC" . corfu-insert-separator)
("C-n" . corfu-next)
("C-p" . corfu-previous))
:custom
(corfu-cycle t)
(corfu-popupinfo-delay '(0.25 . 0.1))
(corfu-popupinfo-hide nil))
(use-package exec-path-from-shell
:if (eq system-type 'darwin)
:ensure t
:config
(exec-path-from-shell-initialize))
(use-package marginalia
:ensure t
:config
(marginalia-mode +1))
(use-package undo-tree
:ensure t
:custom
(undo-tree-auto-save-history nil)
:config
(global-undo-tree-mode +1))
(use-package spacious-padding
:ensure t
:custom
(spacious-padding-subtle-mode-line t)
:config
(spacious-padding-mode +1))
(use-package vertico
:ensure t
:config
(vertico-mode +1))
;;; -- General Development --
(use-package ligature
:ensure t
:hook ((prog-mode . ligature-mode))
:config
(ligature-set-ligatures
'prog-mode
'(".." "..." "::" ":=" ";;" ";;;" "??" "**" "/*" "*/" "/**" "<-"
"->" "-->" "<!--" "<=" "=>" ">=" "<<" ">>" "<>" "<|" "|>" "</"
"/>" "</>" "#(" "#{" "#[" "#!" "##" "###" "####" "[|" "|]" "[<"
">]" "{|" "|}" "{{" "}}" "//" "///" "&&" "++" "||" "==" "==="
"=~" "~-" "__" "!=" "!==" "--" "---")))
(use-package magit
:ensure t
:bind (("C-x g" . magit-status)))
;;; -- OCaml --
(use-package tuareg
:ensure t
:mode (("\\.mli?\\'" . tuareg-mode)
("\\.opam\\'" . tuareg-opam-mode)
("\\.mly\\'" . tuareg-menhir-mode)))
(use-package ocaml-eglot
:ensure t
:after (tuareg)
:hook ((ocaml-eglot . eglot-ensure)))
;;; -- Rust --
(use-package rust-ts-mode
:mode "\\.rs\\'")
;;; -- Solidity --
(if (file-directory-p "~/Developer/nlordell/sol-mode")
(use-package sol-mode
:load-path "~/Developer/nlordell/sol-mode"
:mode "\\.sol\\'")
(use-package sol-mode
:ensure t
:mode "\\.sol\\'"))
;;; -- TypeScript --
(use-package typescript-ts-mode
:mode (("\\.ts\\'" . typescript-ts-mode)
("\\.tsx\\'" . tsx-ts-mode))
:hook ((typescript-ts-mode . init/typescript-eglot-settings)))
;;; -- Miscellaneous --
(use-package dockerfile-mode
:ensure t
:mode "[/\\]Dockerfile")
(use-package markdown-mode
:ensure t
:mode ("\\.md\\'" . gfm-mode)
:hook ((gfm-mode . flyspell-mode)
(gfm-mode . visual-line-mode)
(gfm-mode . init/show-trailing-whitespace)))
(provide 'init)
;;; init.el ends here.
|