-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.el
More file actions
477 lines (445 loc) · 17.9 KB
/
init.el
File metadata and controls
477 lines (445 loc) · 17.9 KB
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
;;; init.el -- -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; User info
(setopt user-full-name "Eugene Mah"
user-mail-address "eugenemah@gmail.com"
user-login-name "eugenem")
(setenv "SHELL" "/bin/fish")
;; General settings
(setopt calendar-week-start-day 1) ; Calendar week starts Monday
(setopt display-time-day-and-date t
display-time-24hr-format t
display-time-default-load-average nil)
;; Electric-pair options
(setopt electric-pair-preserve-balance t
electric-pair-delete-adjacent-pairs t)
(setopt initial-major-mode 'text-mode)
;; Set tab behaviour
(setopt tab-always-indent t
indent-tabs-mode nil
tab-width 4)
(setopt require-final-newline t
use-short-answers t)
;; Abbrev options
(setopt abbrev-suggest t
abbrev-file-name "~/.config/emacs/abbrev_defs") ; Set abbrevs file name
;; Activate modes
(electric-pair-mode) ; Enable electric-pair mode
(display-time-mode) ; Display time in the mode line
(abbrev-mode) ; Enable abbrev mode
(column-number-mode) ; Show column numbers
(show-paren-mode) ; Highlight matching parens
(recentf-mode) ; Remember recently edited files
(global-auto-revert-mode)
(global-display-line-numbers-mode)
(prefer-coding-system 'utf-8)
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
(add-hook 'text-mode-hook 'auto-fill-mode)
;; Fonts
(defvar em/default-font-size 110)
(defvar em/default-variable-font-size 110)
(add-to-list 'default-frame-alist '(font . "Fira Code"))
(set-face-attribute 'default nil
:font "Fira Code"
:height em/default-font-size)
(set-face-attribute 'fixed-pitch nil
:font "Fira Code"
:height em/default-font-size)
(set-face-attribute 'variable-pitch nil
:font "Cantarell"
:height em/default-variable-font-size
:weight 'regular)
;; Backup settings
(setopt backup-directory-alist '(("." . "~/.config/emacs/backups"))
delete-old-versions t
version-control t
vc-make-backup-files t
auto-save-timeout 120
auto-save-file-name-transforms '((".*" "~/.config/emacs/auto-save-list" t)))
;; History settings
(setopt savehist-file "~/.config/emacs/savehist")
(setopt history-delete-duplicates t
history-length 50
history-delete-duplicates t
savehist-save-minibuffer-history t
savehist-additional-variables '(kill-ring
search-ring
regexp-search-ring))
(put 'savehist-minibuffer-history-variables 'history-length 50)
(put 'extended-command-history 'history-length 50)
(put 'command-history 'history-length 50)
(put 'query-replace-history 'history-length 50)
(put 'org-read-date-history 'history-length 50)
(put 'org-table-formula-history 'history-length 50)
;;(put 'helm-M-x-input-history 'history-length 50)
(put 'minibuffer-history 'history-length 50)
(put 'kill-ring 'history-length 50)
(savehist-mode)
;; Mouse button bindings
(keymap-global-set "<mouse-2>" 'mark-whole-buffer) ; wheel button
(keymap-global-set "<mouse-6>" 'backward-word) ; thumb wheel up
(keymap-global-set "<mouse-7>" 'forward-word) ; thumb wheel down
(keymap-global-set "<mouse-8>" 'scroll-up-command) ; forward thumb button
(keymap-global-set "<mouse-9>" 'scroll-down-command) ; back thumb button
(keymap-global-set "<mouse-10>" 'list-buffers)
;; Bootstrap code for straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; Install use-package
;;(straight-use-package 'use-package)
(use-package straight
:custom
(straight-use-package-by-default t))
;; Delete selected text upon insertion
(use-package delsel
:straight (:type built-in)
:ensure nil
:hook (after-init . delete-selection-mode))
;; Use doom modeline
(use-package doom-modeline
:ensure t
:custom
(doom-modeline-time-icon nil)
(doom-modeline-time-live-icon nil)
(doom-modeline-column-zero-based nil)
:hook (after-init . doom-modeline-mode))
(use-package auto-compile
:config
(auto-compile-on-load-mode)
(auto-compile-on-save-mode))
;; Set up for utility packages
(use-package ligature
:demand t
:config
;; Enable the "www" ligature in every possible major mode
(ligature-set-ligatures 't '("www"))
;; Enable all Cascadia and Fira Code ligatures in programming modes
(ligature-set-ligatures
'prog-mode '(;; == === ==== => =| =>>=>=|=>==>> ==< =/=//=// =~
;; =:= =!=
("=" (rx (+ (or ">" "<" "|" "/" "~" ":" "!" "="))))
;; ;; ;;;
(";" (rx (+ ";")))
;; && &&&
("&" (rx (+ "&")))
;; !! !!! !. !: !!. != !== !~
("!" (rx (+ (or "=" "!" "\." ":" "~"))))
;; ?? ??? ?: ?= ?.
("?" (rx (or ":" "=" "\." (+ "?"))))
;; %% %%%
("%" (rx (+ "%")))
;; |> ||> |||> ||||> |] |} || ||| |-> ||-||
;; |->>-||-<<-| |- |== ||=||
;; |==>>==<<==<=>==//==/=!==:===>
("|" (rx (+ (or ">" "<" "|" "/" ":" "!" "}" "\]" "-" "=" ))))
;; \\ \\\ \/
("\\" (rx (or "/" (+ "\\"))))
;; ++ +++ ++++ +>
("+" (rx (or ">" (+ "+"))))
;; :: ::: :::: :> :< := :// ::=
(":" (rx (or ">" "<" "=" "//" ":=" (+ ":"))))
;; // /// //// /\ /* /> /===:===!=//===>>==>==/
("/" (rx (+ (or ">" "<" "|" "/" "\\" "\*" ":" "!" "="))))
;; .. ... .... .= .- .? ..= ..<
("\." (rx (or "=" "-" "\?" "\.=" "\.<" (+ "\."))))
;; -- --- ---- -~ -> ->> -| -|->-->>->--<<-|
("-" (rx (+ (or ">" "<" "|" "~" "-"))))
;; *> */ *) ** *** ****
("*" (rx (or ">" "/" ")" (+ "*"))))
;; www wwww
("w" (rx (+ "w")))
;; <> <!-- <|> <: <~ <~> <~~ <+ <* <$ </ <+> <*>
;; <$> </> <| <|| <||| <|||| <- <-| <-<<-|-> <->>
;; <<-> <= <=> <<==<<==>=|=>==/==//=!==:=>
;; << <<< <<<<
("<" (rx (+ (or "\+" "\*" "\$" "<" ">" ":" "~" "!" "-" "/" "|" "="))))
;; >: >- >>- >--|-> >>-|-> >= >== >>== >=|=:=>>
;; >> >>> >>>>
(">" (rx (+ (or ">" "<" "|" "/" ":" "=" "-"))))
;; #: #= #! #( #? #[ #{ #_ #_( ## ### #####
("#" (rx (or ":" "=" "!" "(" "\?" "\[" "{" "_(" "_" (+ "#"))))
;; ~~ ~~~ ~= ~- ~@ ~> ~~>
("~" (rx (or ">" "=" "-" "@" "~>" (+ "~"))))
;; __ ___ ____ _|_ __|____|_
("_" (rx (+ (or "_" "|"))))
;; Fira code: 0xFF 0x12
("0" (rx (and "x" (+ (in "A-F" "a-f" "0-9")))))
;; Fira code:
"Fl" "Tl" "fi" "fj" "fl" "ft"
;; The few not covered by the regexps.
"{|" "[|" "]#" "(*" "}#" "$>" "^="))
:hook (prog-mode . global-ligature-mode))
;; Rainbow-delimiters
(use-package rainbow-delimiters
:demand t
:hook (prog-mode . rainbow-delimiters-mode))
;; Which-key
(use-package which-key
:straight (:type built-in)
:demand t
:config
(which-key-setup-side-window-right-bottom)
(which-key-mode))
;; Helm
(use-package helm
:custom
(helm-apropos-fuzzy-match t)
(helm-autoresize-mode t)
(helm-display-buffer-default-height 20)
(helm-lisp-fuzzy-completion t)
(helm-locate-fuzzy-match t)
(helm-M-x-fuzzy-match t)
(helm-M-x-show-short-doc t)
(helm-move-to-line-cycle-in-source t)
(helm-scroll-amount 10)
(helm-split-window-default-side "right")
:bind
("C-c h" . helm-command-prefix)
("M-x" . helm-M-x)
("C-x C-f" . helm-find-files)
("M-y" . helm-show-kill-ring)
("C-x b" . helm-mini)
:hook (after-init . helm-mode))
;; Helm key bindings
(global-unset-key (kbd "C-x c"))
;; Company for completions
(use-package company
:straight (:type built-in)
:custom
(company-backends '(company-capf
company-dabbrev-code
company-keywords
company-clang))
(company-frontends '(company-pseudo-tooltip-unless-just-one-frontend-with-delay
company-preview-frontend
company-echo-metadata-frontend))
(company-format-margin-function 'company-vscode-dark-icons-margin)
(company-global-modes '(not shell-mode eaf-mode))
(company-idle-delay 0.1)
(company-minimum-prefix-length 3)
(company-show-numbers t)
(company-tooltip-align-annotations t)
(company-require-match nil)
(company-selection-wrap-around t)
:bind
(:map company-active-map
("<tab>" . company-complete-selection))
:hook (after-init . global-company-mode))
;; Magit
(use-package magit
:straight (:type built-in)
:custom
(magit-credential-cache-daemon-socket nil)
(magit-refresh-status-buffer nil)
(magit-auto-revert-mode t)
(magit-define-global-key-bindings t)
:bind
("C-c C-g s" . magit-status)
("C-c C-g d" . magit-diff)
("C-c C-g D" . magit-diff-unstaged)
("C-c C-g S" . magit-stage)
("C-c C-g U" . magit-unstage)
("C-c C-g c" . magit-commit)
("C-c C-g p" . magit-push)
("C-c C-g P" . magit-pull)
("C-c C-g f" . magit-fetch)
("C-c C-g l" . magit-log)
("C-c C-g b" . magit-branch)
("C-c C-g t" . magit-tag))
;; Flycheck
(use-package flycheck
:straight (:type built-in)
:ensure t
:custom
(flycheck-idle-change-delay 1)
(flycheck-error-list-minimum-level 'warning)
:hook (after-init . global-flycheck-mode))
;; Org mode
(use-package org
:straight (:type built-in)
:custom
(org-directory "~/org/")
(org-agenda-files (list "~/org/todo.org"))
(org-default-notes-file "~/org/notes.org")
(org-archive-location "~/org/archive/")
(org-enable-github-support t)
(org-enable-journal-support t)
(org-log-done 'time-date)
(org-startup-truncated nil)
(org-use-speed-commands t)
(org-return-follows-link t)
(org-tag-alist '(("WORK" . ?W)
("home" . ?h)
("lab" . ?l)
("research" . ?r)
("dogs" . ?d)
("radioclub" . ?C)))
(org-capture-templates '(("t" "Todo"
entry (file+headline "todo.org" "Tasks")
"** TODO %?\n %i\n %a")
("a" "Appointment"
entry (file+headline "todo.org" "Calendar")
"** APPT %^{Description} %^g\n %?\n Added: %U")
("j" "Journal entry"
entry (file+olp+datetree "~/org/journal/journal.org")
"* %?\nEntered on %U\n %i\n %a")
("n" "Notes"
entry (file+olp+datetree "notes.org")
"* %^{Description} %^g %?\n Added: %U")
("s" "Scractchpad"
entry (file+olp+datetree "scratchpad.org" "Scratchpad")
"** %^{Description} %^g %?\n Added: %U")
("l" "Lab book"
entry (file+olp+datetree "PhD/notes.org")
"* %U\n %?\n %i\n %a"))))
;; Org journal
(use-package org-journal
:init
(setq org-journal-prefix-key "C-c j")
:custom
(setq org-journal-dir "~/org/journal/"
org-journal-enable-agenda-integration t
org-journal-file-type 'year))
;; Programming modes
;; tree-sitter
(setq treesit-language-source-alist
'((arduino "https://github.com/tree-sitter-grammars/tree-sitter-arduino")
(bash "https://github.com/tree-sitter/tree-sitter-bash")
(c "https://github.com/tree-sitter/tree-sitter-c")
(cmake "https://github.com/uyha/tree-sitter-cmake")
(cpp "https://github.com/tree-sitter/tree-sitter-cpp")
(css "https://github.com/tree-sitter/tree-sitter-css")
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
(go "https://github.com/tree-sitter/tree-sitter-go")
(html "https://github.com/tree-sitter/tree-sitter-html")
(java "https://github.com/tree-sitter/tree-sitter-java")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc")
(json "https://github.com/tree-sitter/tree-sitter-json")
(julia "https://github.com/tree-sitter/tree-sitter-julia")
(make "https://github.com/alemuller/tree-sitter-make")
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
(php "https://github.com/tree-sitter/tree-sitter-php" "v0.23.12" "php/src")
(phpdoc "https://github.com/claytonrcarter/tree-sitter-phpdoc")
(python "https://github.com/tree-sitter/tree-sitter-python")
(rust "https://github.com/tree-sitter/tree-sitter-rust")
(toml "https://github.com/tree-sitter/tree-sitter-toml")
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
(yaml "https://github.com/ikatyang/tree-sitter-yaml")))
(setopt major-mode-remap-alist
'((bash-mode . bash-ts-mode)
(c-mode . c-ts-mode)
(cmake-mode . cmake-ts-mode)
(cpp-mode . cpp-ts-mode)
(css-mode . css-ts-mode)
(go-mode . go-ts-mode)
(java-mode . java-ts-mode)
(javascript-mode . javascript-ts-mode)
(json-mode . json-ts-mode)
(markdown-mode . markdown-ts-mode)
(php-mode . php-ts-mode)
(python-mode . python-ts-mode)
(rust-mode . rust-ts-mode)
(toml-mode . toml-ts-mode)
(yaml-mode . yaml-ts-mode)))
(setq treesit-load-name-override-list '((gomod "libtree-sitter-go")))
;; ;; eglot
;; (setq eglot-autoshutdown t
;; lsp-phpactor-path "phpactor")
;; (with-eval-after-load 'eglot
;; (add-to-list 'eglot-server-programs
;; '(php-mode . ("phpactor" "language-server"))))
;; (add-hook 'php-mode-hook 'eglot-ensure)
;; Markdown mode
(use-package markdown-mode
:ensure t
:custom
(markdown-enable-wiki-links t)
(markdown-enable-math t)
(markdown-command "multimarkdown"))
;; Fish shell
(use-package fish-mode
:custom
(fish-enable-auto-indent t))
;; PHP
(use-package php-mode
:defer t
:custom
(php-mode-coding-style 'psr2)
:mode ("\\.php\\'"))
(use-package company-php
:defer t
:after (php-mode company))
(use-package ac-php
:defer t
:after (php-mode company))
(with-eval-after-load 'php-mode
(add-hook 'php-mode-hook
#'(lambda ()
;; Enable ElDoc support (optional)
(ac-php-core-eldoc-setup)
(set (make-local-variable 'company-backends)
'((company-ac-php-backend company-dabbrev-code)
company-capf company-files))
;; Jump to definition (optional)
(define-key php-mode-map (kbd "M-]")
'ac-php-find-symbol-at-point)
;; Return back (optional)
(define-key php-mode-map (kbd "M-[")
'ac-php-location-stack-back)))
(define-key php-mode-map (kbd "C-c C--") 'php-current-class)
(define-key php-mode-map (kbd "C-c C-=") 'php-current-namespace))
;; Define a minor mode to hold some of my keybindings
(define-minor-mode em-keymaps-mode
"Personal keybindings."
:init-value nil
:global t
:keymap (let ((map (make-sparse-keymap)))
;; Emacs frame-related keybindings
(define-key map (kbd "C-c C-f d") 'delete-frame)
(define-key map (kbd "C-c C-f n") 'make-frame)
(define-key map (kbd "C-c C-f o") 'other-frame)
(define-key map (kbd "C-c C-f l") 'lower-frame)
(define-key map (kbd "C-c C-f r") 'raise-frame)
;; Org-mode keybindings
(define-key map (kbd "C-c l") #'org-store-link)
(define-key map (kbd "C-c a") #'org-agenda)
(define-key map (kbd "C-c c") #'org-capture)
(define-key map (kbd "C-c .") #'org-time-stamp)
(define-key map (kbd "C-c ,") #'org-time-stamp-inactive)
;; EasyPG interface for GPG
(define-key map (kbd "C-c M-e l") 'epa-list-keys)
(define-key map (kbd "C-c M-e L") 'epa-list-secret-keys)
(define-key map (kbd "C-c M-e v") 'epa-verify-region)
(define-key map (kbd "C-c M-e V") 'epa-verify-file)
(define-key map (kbd "C-c M-e d") 'epa-decrypt-region)
(define-key map (kbd "C-c M-e D") 'epa-decrypt-file)
(define-key map (kbd "C-c M-e e") 'epa-encrypt-region)
(define-key map (kbd "C-c M-e E") 'epa-encrypt-file)
(define-key map (kbd "C-c M-e s") 'epa-sign-region)
(define-key map (kbd "C-c M-e S") 'epa-sign-file)
;; Other keybindings
(define-key map (kbd "C-c ;") 'comment-or-uncomment-region)
(define-key map (kbd "<escape>") 'keyboard-escape-quit)
(define-key map (kbd "C-c C-a") 'mark-whole-buffer)
(define-key map (kbd "C-c C-p") 'mark-paragraph)
map))
(add-hook 'after-init-hook 'em-keymaps-mode)
(em-keymaps-mode 1)
(provide 'init)
;;; init.el ends here