-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.el
384 lines (321 loc) · 11.9 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
;; A minimial setup for Clojurians
;; Reduce the frequency of garbage collection by making it happen on
;; each 50MB of allocated data (the default is on every 0.76MB)
(setq gc-cons-threshold 50000000
gc-cons-percentage 0.6)
;; Automatically reload files when they change on disk
(global-auto-revert-mode 1)
(setq auto-revert-verbose nil)
(setq package-enable-at-startup nil)
;; Bootstrap configuration for straight.el
(setq straight-use-package-by-default t
;; use-package-always-defer t
straight-cache-autoloads t
straight-vc-git-default-clone-depth 1
vc-follow-symlinks t
straight-check-for-modifications '(check-on-save find-when-checking)
straight-recipes-emacsmirror-use-mirror nil)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
;; Move custom configuration variables set by Emacs, to a seperate temporary file
;; (setq custom-file "~/.emacs.d/custom.el")
(setq custom-file (make-temp-file "emacs-custom-"))
(load custom-file 'noerror)
;;
;; APPEARANCE
;;
;; prevent the glimpse of unstyled UI elements
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
;; initial starting position
(push '(height . 43) default-frame-alist)
(push '(width . 130) default-frame-alist)
(push '(left . 70) default-frame-alist)
(push '(top . 30) default-frame-alist)
;; disable GUI elements
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(setq frame-resize-pixelwise t
frame-inhibit-implied-resize t
frame-title-format '("%b")
ring-bell-function 'ignore
use-dialog-box t
use-file-dialog nil
use-short-answers t
inhibit-splash-screen t
inhibit-startup-screen t
inhibit-startup-echo-area-message user-login-name
inhibit-startup-buffer-menu t
comp-deferred-compilation nil
frame-resize-pixelwise t
cursor-in-non-selected-windows nil
site-run-file nil
system-time-locale "en_US.utf8"
initial-major-mode 'markdown-mode
initial-scratch-message nil)
;; Make the title bar blend with the background color
;; Set the appearance to light/dark depending on your theme
(add-to-list 'default-frame-alist
'(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist
'(ns-appearance . dark))
;; Show full file path in the title bar
(setq
frame-title-format
'((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))
;; Line numbers
;; Add some padding when displaying line numbers
(setq linum-format "%5d ")
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
;;
;; SANE DEFAULTS
;;
;; Make native compilation silent and prune its cache.
(setq native-comp-async-report-warnings-errors 'silent)
(setq native-compile-prune-cache t)
;; Use y/n instead of full yes/no for confirmation messages
(fset 'yes-or-no-p 'y-or-n-p)
;; Use spaces instead of tabs
(setq tab-width 2)
(setq js-indent-level 2)
(setq css-indent-offset 2)
(setq c-basic-offset 2)
(setq-default indent-tabs-mode nil)
(setq-default c-basic-offset 2)
(setq-default tab-width 2)
(setq-default c-basic-indent 2)
;; Type over selected text
(delete-selection-mode 1)
;; Kill whole line
(global-set-key (kbd "s-<backspace>") 'kill-whole-line)
;; Use Cmd for movement
(global-set-key (kbd "s-<right>") (kbd "C-e")) ;; End of line
(global-set-key (kbd "s-<left>") (kbd "C-a")) ;; Beginning of line
;; Kills the current buffer without displaying the annoying menu.
;; A confirmation will be asked for, if the buffer has been modified
(global-set-key (kbd "C-x k") 'kill-current-buffer)
;; Remove trailing whitespace before saving
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Follow compilation buffer output
(setq compilation-scroll-output t)
;; On OS X, an Emacs instance started from the graphical user
;; interface will have a different environment than a shell in a
;; terminal window, because OS X does not run a shell during the
;; login. Obviously this will lead to unexpected results when
;; calling external utilities like make from Emacs.
;; This library works around this problem by copying important
;; environment variables from the user's shell.
;; https://github.com/purcell/exec-path-from-shell
(use-package exec-path-from-shell
:config
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize)))
(use-package clojure-mode)
(require 'clojure-mode)
;; Then define your custom syntax table
;; (defvar clojure-mode-with-hyphens-as-word-sep-syntax-table
;; (let ((st (make-syntax-table clojure-mode-syntax-table)))
;; (modify-syntax-entry 45 "w" st)
;; st))
;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
(use-package vertico
:custom
(vertico-cycle nil)
(read-file-name-completion-ignore-case t)
(read-buffer-completion-ignore-case t)
(completion-ignore-case t)
:config
(vertico-mode))
(use-package marginalia
:after vertico
:init
(marginalia-mode))
(use-package consult
:bind (("s-b" . consult-buffer)
("M-g g" . consult-goto-line)
("M-g o" . consult-outline)
("M-g l" . consult-line)
("M-g f" . consult-find))
:config
(setq consult-find-args "find . -not ( -path */.[A-Za-z]* -prune )")
;; (use-package consult-selectrum
;; :after selectrum
;; :demand t)
)
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
;; Install and setup company-mode for autocompletion
(use-package company
:bind (("C-p" . company-select-previous)
("C-n" . company-select-next))
:init
(add-hook 'prog-mode-hook 'company-mode)
:config
(global-company-mode)
(setq company-tooltip-limit 10)
(setq company-idle-delay 0.2)
(setq company-echo-delay 0)
(setq company-minimum-prefix-length 2)
(setq company-require-match nil)
(setq company-selection-wrap-around t)
(setq company-tooltip-align-annotations t)
(setq company-tooltip-flip-when-above nil)
(setq company-dabbrev-ignore-case nil
company-dabbrev-downcase nil)
;; weight by frequency
(setq company-transformers '(company-sort-by-occurrence)))
;; Better syntax highlighting
;;(use-package clojure-mode-extra-font-locking)
;; Highlight matching parentheses
(require 'paren)
(show-paren-mode 1)
(setq show-paren-delay 0.125)
(set-face-background 'show-paren-match (face-background 'default))
(if (eq (frame-parameter nil 'background-mode) 'dark)
(set-face-foreground 'show-paren-match "red")
(set-face-foreground 'show-paren-match "black"))
(set-face-attribute 'show-paren-match nil :weight 'extra-bold)
;; Add ability to shift between buffers using shift+arrow keys.
(when (fboundp 'windmove-default-keybindings)
(windmove-default-keybindings))
;; Paredit makes it easier to navigate/edit s-expressions as blocks.
(use-package paredit
:config
(add-hook 'emacs-lisp-mode-hook #'paredit-mode)
(add-hook 'clojure-mode-hook
(lambda ()
(paredit-mode)
(local-set-key (kbd "<C-s-right>") #'paredit-forward-slurp-sexp)
(local-set-key (kbd "<C-s-left>") #'paredit-forward-barf-sexp))))
;; To add some colors to those boring parens
(use-package rainbow-delimiters
:init (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
(use-package clojure-mode
:straight (:type built-in)
:config
;;Treat hyphens as a word character when transposing words
(defvar clojure-mode-with-hyphens-as-word-sep-syntax-table
(let ((st (make-syntax-table clojure-mode-syntax-table)))
(modify-syntax-entry ?- "w" st)
st))
(defun transpose-words-with-hyphens (arg)
"Treat hyphens as a word character when transposing words"
(interactive "*p")
(with-syntax-table clojure-mode-with-hyphens-as-word-sep-syntax-table
(transpose-words arg)))
(define-key clojure-mode-map (kbd "M-t") 'transpose-words-with-hyphens))
(define-clojure-indent
(defrecord 1)
(as-> 2))
;; Cider integrates a Clojure buffer with a REPL
(use-package cider
:init
;; (add-to-list 'auto-mode-alist '("\\.clj\\'" . go-mode))
(setq cider-repl-pop-to-buffer-on-connect t
cider-show-error-buffer t
cider-auto-select-error-buffer t
cider-repl-history-file "~/.emacs.d/cider-history"
cider-repl-wrap-history t
cider-repl-history-size 100
cider-repl-use-clojure-font-lock t
cider-docview-fill-column 70
cider-stacktrace-fill-column 76
nrepl-popup-stacktraces nil
nrepl-log-messages nil
nrepl-hide-special-buffers t
cider-repl-use-pretty-printing t
cider-repl-result-prefix ";; => "
cider-repl-display-help-banner nil
cider-font-lock-dynamically '(macro core function var))
:config
(add-hook 'clojure-mode-hook #'cider-mode)
(add-hook 'cider-mode-hook #'eldoc-mode)
(add-hook 'cider-repl-mode-hook #'paredit-mode)
(add-hook 'cider-repl-mode-hook #'company-mode)
(add-hook 'cider-repl-mode-hook
(lambda ()
(local-set-key (kbd "C-l") 'cider-repl-clear-buffer)))
(add-hook 'cider-mode-hook #'company-mode)
(add-hook 'cider-mode-hook
(lambda ()
(local-set-key (kbd "<C-return>") 'cider-eval-last-sexp)
(local-set-key (kbd "C-c C-n") 'cider-eval-buffer)
(local-set-key (kbd "C-x C-i") 'cider-inspect-last-sexp))))
;; Adds some niceties/refactoring support
(use-package clj-refactor
:config
(setq cljr-warn-on-eval nil)
(add-hook 'clojure-mode-hook
(lambda ()
(clj-refactor-mode 1))))
(use-package flycheck-clj-kondo
:config
(remove-hook 'clojure-mode-hook
(lambda ()
(require 'flycheck-clj-kondo))))
;; Aggressively indents your clojure code
(use-package aggressive-indent
:commands (aggressive-indent-mode)
:config
(add-hook 'clojure-mode-hook 'aggressive-indent-mode))
;; Operate (list, search, replace....) on files at a project level.
(use-package projectile
:bind (:map projectile-mode-map
("s-p" . projectile-command-map))
:init
(setq-default projectile-cache-file
(expand-file-name ".projectile-cache" user-emacs-directory))
(add-hook 'prog-mode-hook #'projectile-mode)
:config
(projectile-mode)
;; (setq projectile-completion-system 'ivy)
(setq-default projectile-enable-caching t
projectile-mode-line-prefix ""
projectile-sort-order 'recentf
;; Show project (if any) name in modeline
projectile-mode-line '(:eval (projectile-project-name))))
;; Magit: The only git interface you'll ever need
(use-package magit
:bind ("C-x g" . 'magit-status)
:config
(setq magit-set-upstream-on-push 'askifnotset
magit-push-always-verify nil
magit-revert-buffers 'silent
magit-diff-highlight-indentation nil
magit-diff-paint-whitespace nil
magit-diff-highlight-trailing nil))
;; User customizations
;; Add your customizations to `init-user.el`
(when (file-exists-p "~/.emacs.d/init-user.el")
(setq user-custom-file "~/.emacs.d/init-user.el")
(load user-custom-file)
(put 'downcase-region 'disabled nil))
(put 'narrow-to-region 'disabled nil)
(require 'server)
(unless (server-running-p)
(server-start))
;; Reset GC to reasonable defaults
(add-hook 'emacs-startup-hook
(lambda ()
(setq gc-cons-threshold 16777216
gc-cons-percentage 0.1)))