-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
240 lines (204 loc) · 5.95 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
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(setq package-native-compile t)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(setq use-package-always-ensure t)
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(use-package no-littering
:ensure t
:init
(setq auto-save-file-name-transforms
`((".*" ,(no-littering-expand-var-file-name "auto-save/") t)))
(setq no-littering-etc-directory
(expand-file-name "config/" user-emacs-directory))
(setq no-littering-var-directory
(expand-file-name "data/" user-emacs-directory))
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(unless (recentf-mode))
(add-to-list 'recentf-exclude no-littering-var-directory)
(add-to-list 'recentf-exclude no-littering-etc-directory))
(defun zerodouglas/comment-paragraph ()
(interactive)
(save-excursion
(mark-paragraph)
(comment-or-uncomment-region (region-beginning) (region-end))))
(global-set-key (kbd "C-c c") 'zerodouglas/comment-paragraph)
(defun eglot-format-buffer-on-save ()
(add-hook 'before-save-hook #'eglot-format-buffer -10 t))
(add-hook 'go-mode-hook #'eglot-format-buffer-on-save)
(global-set-key (kbd "<f2>") 'kmacro-start-macro)
(global-set-key (kbd "<f3>") 'kmacro-end-macro)
(global-set-key (kbd "<f4>") 'call-last-kbd-macro)
(use-package emacs
:custom
(delete-selection-mode t)
(show-paren-mode 1))
(use-package which-key
:init
(which-key-mode))
(use-package envrc
:config
:hook (prog-mode . envrc-global-mode))
(cl-defmacro def-repeat-map (name &key keys exit-with)
(declare (indent 0))
(let ((def-repeat-map-result nil))
(when exit-with
(push `(define-key ,name ,(kbd exit-with) #'keyboard-quit)
def-repeat-map-result))
(dolist (key (map-pairs keys))
(push `(define-key ,name ,(car key) ,(cdr key))
def-repeat-map-result)
(push `(put ,(cdr key) 'repeat-map ',name)
def-repeat-map-result))
`(progn
(defvar ,name (make-sparse-keymap))
,@def-repeat-map-result)))
(use-package repeat
:ensure nil
:init (repeat-mode 1)
:config
(def-repeat-map puni-expand-repeat-map
:keys ("." #'puni-expand-region))
(def-repeat-map forward-word-repeat-map
:keys ("f" #'forward-word
"b" #'backward-word)
:exit-with "RET"))
(setq-default
fill-column 80
mark-ring-max 6
global-mark-ring-max 6
left-margin-width 1
sentence-end-double-space nil
kill-whole-line t)
(use-package go-mode)
(use-package haskell-mode
:defer t
:commands (haskell-mode)
:init
(defun ebn/haskell-mode-setup ()
(interactive)
(setq-local eldoc-documentation-function #'haskell-doc-current-info
tab-stop-list '(2)
indent-line-function #'indent-relative
tab-width 2)
(interactive-haskell-mode)
(haskell-indentation-mode)
(electric-pair-mode))
(add-hook 'haskell-mode-hook #'ebn/haskell-mode-setup)
:custom
(haskell-process-type 'cabal-repl)
(haskell-process-load-or-reload-prompt nil)
(haskell-process-auto-import-loaded-modules t)
(haskell-process-log t)
(haskell-interactive-popup-errors nil)
(haskell-font-lock-symbols t)
:config
(defun haskell-mode-after-save-handler ()
(let ((inhibit-message t))
(eglot-format-buffer))))
(use-package eglot
:ensure t
:hook
(haskell-mode . eglot-ensure)
(go-mode . eglot-ensure)
:custom
(eglot-autoshutdown t)
(eglot-autoreconnect nil)
(eglot-confirm-server-initiated-edits nil)
(eldoc-idle-delay 1)
(eldoc-echo-area-display-truncation-message nil)
(eldoc-echo-area-use-multiline-p 2))
(use-package corfu
:custom
(corfu-auto-delay 0.2)
(corfu-cycle t)
(corfu-auto t)
(corfu-commit-predicate nil)
(corfu-quit-at-boundary t)
(corfu-quit-no-match t)
(corfu-echo-documentation nil)
:config
(global-corfu-mode))
(use-package vertico
:init
(defvar last-file-name-handler-alist nil)
(vertico-mode))
;; Don't need Puni
(use-package puni
:disabled
:ensure t
:init
(puni-global-mode)
(electric-pair-mode)
:bind
("C-." . puni-expand-region))
(use-package paredit
:hook
(lisp-mode . paredit-mode)
(emacs-lisp-mode . paredit-mode))
(use-package nix-mode
:defer t
:mode ("\\.nix\\'" . nix-mode))
(use-package doom-themes
:config
(load-theme 'doom-wilmersdorf t))
(use-package vertico
:ensure
:init
(vertico-mode))
(use-package orderless
:commands (orderless)
:custom (completion-styles '(orderless flex)))
(use-package consult
:ensure t
:init
(setq consult-preview-key nil)
(recentf-mode)
:bind
(:map global-map
("C-c r" . consult-recent-file)
("C-c f" . consult-ripgrep)
("C-c l" . consult-line)
("C-c i" . consult-imenu)
("C-x b" . consult-buffer)
("C-c x" . consult-complex-command))
(:map comint-mode-map
("C-c C-l" . consult-history)))
(defun zerodouglas/kill-current-buffer ()
"Kill current buffer."
(interactive)
(kill-buffer (current-buffer)))
(defun zerodouglas/dired-up-directory ()
"Up directory - killing current buffer."
(interactive)
(let ((cb (current-buffer)))
(progn (dired-up-directory)
(kill-buffer cb))))
(defun zerodouglas/copy-dwim ()
"Run the command `kill-ring-save' on the current region
or the current line if there is no active region."
(interactive)
(if (region-active-p)
(kill-ring-save nil nil t)
(kill-ring-save (point-at-bol) (point-at-eol))))
(put 'narrow-to-region 'disabled nil)
(global-set-key (kbd "C-x k") 'zerodouglas/kill-current-buffer)
(global-set-key (kbd "M-w") 'zerodouglas/copy-dwim)
(use-package dired
:ensure nil
:config
(setq dired-recursive-copies t
dired-recursive-deletes t
dired-dwim-target t
delete-by-moving-to-trash t)
:bind* (:map dired-mode-map
("-" . zerodouglas/dired-up-directory)))
;; Install Roswell
(use-package sly
:config
(setq sly-default-lisp 'roswell
sly-lisp-implementations
`((roswell ("ros" "-Q" "run")))))