-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
executable file
·253 lines (233 loc) · 8.24 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
;;; init.el --- init
;;; Commentary:
;; -*- lexical-binding: t; -*-
;;; Code:
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(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))
(setq-default straight-use-package-by-default t)
;; global minor modes
(use-package corfu
:demand t
:hook (prog-mode . corfu-mode)
:custom (corfu-auto t) (corfu-auto-delay 0.2) (corfu-cycle t) (corfu-quit-no-match t) (corfu-preselect 'prompt)
:bind (:map corfu-map
("TAB" . corfu-next)
("S-TAB" . corfu-previous)))
(use-package orderless
:demand t
:custom (completion-styles '(basic partial-completion emacs22 orderless initials substring)))
(use-package cape
:demand t
:config
(setq completion-at-point-functions (list (cape-super-capf #'cape-keyword #'cape-file #'cape-dabbrev))))
(use-package which-key
:demand t
:config
(which-key-setup-side-window-right)(which-key-mode))
(use-package undo-tree ;; note: this is a handy tree history browser, but it will pollute your directories with `.file.~undo-tree~` files
:demand t
:config (global-undo-tree-mode))
(use-package flycheck
:demand t
:config (global-flycheck-mode)
:bind (:map flycheck-mode-map)
("M-n" . flycheck-next-error)
("M-p" . flycheck-previous-error))
(use-package vertico
:demand t
:config (vertico-mode))
(global-auto-revert-mode)
(use-package diff-hl
:hook (prog-mode text-mode)
:config (diff-hl-margin-mode))
(when (display-graphic-p)
(use-package all-the-icons
:demand t))
;; (use-package dashboard ;; you might want to uncomment this later, it creates a more useful dashboard but hides some beginner info
;; :config
;; (dashboard-setup-startup-hook))
(use-package marginalia
:demand t
:config (marginalia-mode)
:bind
(:map minibuffer-local-map
("M-A" . marginalia-cycle)))
(use-package tempel
;; Require trigger prefix before template name when completing.
:custom (tempel-trigger-prefix "<")
:bind (("M-+" . tempel-complete)
("M-*" . tempel-insert))
:init
;; Setup completion at point
(defun tempel-setup-capf ()
;; Add the Tempel Capf to 'completion-at-point-functions'.
;; 'tempel-expand' only triggers on exact matches. Alternatively use
;; 'tempel-complete' if you want to see all matches, but then you
;; should also configure 'tempel-trigger-prefix', such that Tempel
;; does not trigger too often when you don't expect it. NOTE: We add
;; 'tempel-expand' *before* the main programming mode Capf, such
;; that it will be tried first.
(setq-local completion-at-point-functions
(cons #'tempel-expand
completion-at-point-functions)))
(add-hook 'prog-mode-hook 'tempel-setup-capf)
(add-hook 'text-mode-hook 'tempel-setup-capf))
(use-package tempel-collection
:requires (tempel)
:demand t)
(use-package hideshow
:straight nil
:demand t
:hook (prog-mode . hs-minor-mode))
;; (use-package embark ;; one of my favourite packages, but needs some experience
;; :demand t
;; :bind
;; ("C-M-SPC" . embark-act)
;; ("C-." . embark-dwim)
;; ("M-/" . embark-export))
;; (use-package helpful ;; seems to be broken in 29.0.91, but fixed 30.0.50
;; :demand t
;; :bind
;; (("C-h f" . helpful-callable)
;; ("C-h v" . helpful-variable)
;; ("C-h k" . helpful-key)
;; ("C-h F" . helpful-function)
;; ("C-h C" . helpful-command)
;; ("C-c C-d" . helpful-at-point)))
(use-package treesit-auto
:config (setq treesit-auto-langs '()) (global-treesit-auto-mode)) ;; don't forget to set treesit-auto-langs to the languages you want to install, then run `treesit-auto-install-all`
;; (use-package bufler ;; makes `switch-buffer` nicer, but more verbose
;; :demand t
;; :config (bufler-mode)
;; :bind
;; ("C-x b" . bufler-switch-buffer)
;; ("C-x C-b" . bufler-list))
;; global functions
(defun indent-buffer ()
"Indent the entire buffer."
(interactive)
(indent-region 0 (buffer-size)))
(use-package eglot-super-capf
:demand t
:requires (eglot cape tempel)
:config
(defun eglot-cape-tempel-capf ()
(setq-local completion-at-point-functions
(list (cape-super-capf #'eglot-completion-at-point #'tempel-expand #'cape-file)))))
;; global settings
(electric-pair-mode)
(save-place-mode)
(global-display-line-numbers-mode)
;; (menu-bar--display-line-numbers-mode-relative) ;; uncomment for relative line numbers
(setq-default shell-file-name "bash") ;; set "bash" to the shell you use the most
;; (scroll-bar-mode -1) ;; you might want to uncomment this
;; (tool-bar-mode -1) ;; you might want to uncomment this
;; (menu-bar-mode -1) ;; you might want to uncomment this
(setq-default tab-width 2 indent-tabs-mode t)
(setq debug-on-error t)
(setq load-prefer-newer t)
(setq sentence-end-double-space t)
(setq make-backup-files nil select-enable-clipboard t)
(setq gc-cons-threshold (* 100 1024 1024))
;; (defalias 'yes-or-no-p 'y-or-n-p) ;; uncomment for more convenient prompts, might be a bit unsafe
(setq inital-frame-alist '((vertical-scroll-bars) (fullscreen . maximized)))
(setq next-line-add-newlines t)
(setq completion-cycle-threshold 3)
(setq tab-always-indent 'complete)
;; unbinds
(unbind-key (kbd "<insert>")) ;; overwrite-mode
(unbind-key (kbd "<insertchar>")) ;; overwrite-mode
;; LSP
(use-package eglot
:straight nil
:requires (orderless cape)
:defer t
:custom (completion-category-overrides '((eglot (styles orderless))))
:config (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
:hook (eglot-managed-mode . eglot-cape-tempel-capf))
;; Git
(use-package magit
:demand t
:bind
("C-c g" . magit))
;; Debug
(defun debug-gud ()
"GUD setup for Rust and core files."
(interactive)
(cond ((and (or (equal major-mode 'c-mode) (equal major-mode 'c++-mode)) (file-exists-p "./core"))
((setq gud-gdb-command-name "gdb -i=mi ./core") (gud-gdb)))
((equal major-mode 'rust-mode) (rust-gdb))))
;; Lisp
(use-package paredit
:defer t
:hook
(lisp-mode eval-expression-minibuffer-setup lisp-interaction-mode slime-repl-mode emacs-lisp-mode scheme-mode)
:bind
(:map paredit-mode-map
("M-<right>" . paredit-forward-slurp-sexp)
("M-<left>" . paredit-forward-barf-sexp)
("C-<left>" . paredit-backward-slurp-sexp)
("C-<right>" . paredit-backward-barf-sexp)
("M-r" . move-to-window-line-top-bottom)
("C-k" . paredit-kill))) ; todo bind paredit-forward and paredit-backward and paredit-kill
(use-package highlight-function-calls
:hook (lisp-mode emacs-lisp-mode scheme-mode))
(use-package lisp-extra-font-lock
:config (lisp-extra-font-lock-global-mode))
(use-package rainbow-delimiters
:defer t
:hook (lisp-mode emacs-lisp-mode scheme-mode))
;; Dired
(use-package all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
;; Org
(use-package org
:straight nil
:defer t
:config (add-to-list 'org-file-apps '(directory . emacs)))
;; (use-package org-modern ;; prettier look for org-mode, may impede learning it
;; :requires org
;; :demand t
;; :hook ((org-mode) (org-agenda-finalize . org-modern-agenda)))
(use-package org-babel
:straight nil
:requires org
:defer t
:config
((org-babel-do-load-languages
'org-babel-load-languages
'((shell . t)
(emacs-lisp . t)
(arduino . t)
(lisp . t)
(makefile . t)
(org . t)
(calc . t)
(C . t)
(cpp . t)
(eshell . t)
(scheme . t)))
(setq org-src-preserve-indentation t org-src-fontify-natively t org-confirm-babel-evaluate nil)))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(warning-suppress-types '((comp))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;; init.el ends here