diff options
Diffstat (limited to '.config/emacs/Emacs.org')
-rw-r--r-- | .config/emacs/Emacs.org | 520 |
1 files changed, 520 insertions, 0 deletions
diff --git a/.config/emacs/Emacs.org b/.config/emacs/Emacs.org new file mode 100644 index 0000000..c151ad5 --- /dev/null +++ b/.config/emacs/Emacs.org | |||
@@ -0,0 +1,520 @@ | |||
1 | #+title: Emacs Configuration | ||
2 | #+author: jdlugosz963 | ||
3 | #+PROPERTY: header-args:emacs-lisp :tangle ./init.el | ||
4 | |||
5 | * Table of contents :toc: | ||
6 | :PROPERTIES: | ||
7 | :TOC: :include all | ||
8 | :END: | ||
9 | :CONTENTS: | ||
10 | - [[#table-of-contents][Table of contents]] | ||
11 | - [[#user-information-setup][User information setup]] | ||
12 | - [[#startup-performance][Startup Performance]] | ||
13 | - [[#package-setup][Package setup]] | ||
14 | - [[#keboard-setup][Keboard Setup]] | ||
15 | - [[#general-setup][General Setup]] | ||
16 | - [[#evil-mode-setup][Evil mode setup]] | ||
17 | - [[#keybinds][Keybinds]] | ||
18 | - [[#ui-configuration][UI Configuration]] | ||
19 | - [[#basic-ui-setup][Basic UI setup]] | ||
20 | - [[#ivy-and-counsel][Ivy and Counsel]] | ||
21 | - [[#keybinds][Keybinds]] | ||
22 | - [[#which-key][Which key]] | ||
23 | - [[#modline][Modline]] | ||
24 | - [[#other-keybindings][Other Keybindings]] | ||
25 | - [[#files][Files]] | ||
26 | - [[#eval][Eval]] | ||
27 | - [[#buffers][Buffers]] | ||
28 | - [[#org][Org]] | ||
29 | - [[#org-mode-setup][Org-mode setup]] | ||
30 | - [[#keybinds][Keybinds]] | ||
31 | - [[#org-make-toc][Org make toc]] | ||
32 | - [[#org-fonts][Org fonts]] | ||
33 | - [[#org-tempo-setup][Org tempo setup]] | ||
34 | - [[#org-babel-setup][Org babel setup]] | ||
35 | - [[#auto-tangle][Auto tangle]] | ||
36 | - [[#org-margin][Org margin]] | ||
37 | - [[#org-superstar][Org superstar]] | ||
38 | - [[#development][Development]] | ||
39 | - [[#projectile][Projectile]] | ||
40 | - [[#keybinds][Keybinds]] | ||
41 | - [[#magit][Magit]] | ||
42 | - [[#keybinds][Keybinds]] | ||
43 | - [[#apps][Apps]] | ||
44 | - [[#vterm][Vterm]] | ||
45 | - [[#keybinds][Keybinds]] | ||
46 | - [[#dired][Dired]] | ||
47 | :END: | ||
48 | |||
49 | |||
50 | * User information setup | ||
51 | |||
52 | #+begin_src emacs-lisp | ||
53 | |||
54 | (setq user-full-name "Jakub Dlugosz" | ||
55 | user-mail-address "jdlugosz963@gmail.com") | ||
56 | |||
57 | #+end_src | ||
58 | |||
59 | * Startup Performance | ||
60 | |||
61 | #+begin_src emacs-lisp | ||
62 | |||
63 | (setq gc-cons-threshold (* 50 1000 1000)) | ||
64 | |||
65 | (defun jd/display-startup-time () | ||
66 | (message "Emacs loaded in %s with %d garbage collections." | ||
67 | (format "%.2f seconds" | ||
68 | (float-time | ||
69 | (time-subtract after-init-time before-init-time))) | ||
70 | gcs-done)) | ||
71 | |||
72 | (add-hook 'emacs-startup-hook #'jd/display-startup-time) | ||
73 | |||
74 | #+end_src | ||
75 | |||
76 | * Package setup | ||
77 | |||
78 | #+begin_src emacs-lisp | ||
79 | |||
80 | (require 'package) | ||
81 | (setq package-archives '(("melpa" . "https://melpa.org/packages/") | ||
82 | ("org" . "https://orgmode.org/elpa/") | ||
83 | ("gnu-devel" . "https://elpa.gnu.org/devel/") | ||
84 | ("elpa" . "https://elpa.gnu.org/packages/"))) | ||
85 | (package-initialize) | ||
86 | |||
87 | (unless package-archive-contents | ||
88 | (package-refresh-contents)) | ||
89 | |||
90 | (unless (package-installed-p 'use-package) | ||
91 | (package-install 'use-package)) | ||
92 | |||
93 | (setq use-package-always-ensure t) | ||
94 | |||
95 | (require 'use-package) | ||
96 | |||
97 | #+end_src | ||
98 | |||
99 | * Keboard Setup | ||
100 | ** General Setup | ||
101 | |||
102 | #+begin_src emacs-lisp | ||
103 | |||
104 | (use-package general | ||
105 | :config | ||
106 | (general-create-definer jd/leader-key-def | ||
107 | :keymaps '(normal insert visual emacs) | ||
108 | :prefix "SPC" | ||
109 | :global-prefix "C-SPC") | ||
110 | |||
111 | (general-create-definer jd/ctrl-c-keys | ||
112 | :prefix "C-c")) | ||
113 | |||
114 | #+end_src | ||
115 | |||
116 | ** Evil mode setup | ||
117 | |||
118 | #+begin_src emacs-lisp | ||
119 | |||
120 | (use-package undo-tree | ||
121 | :config | ||
122 | (setq undo-tree-auto-save-history nil) | ||
123 | (global-undo-tree-mode 1)) | ||
124 | |||
125 | (use-package evil | ||
126 | :init | ||
127 | (setq evil-want-integration t) | ||
128 | (setq evil-want-keybinding nil) | ||
129 | (setq evil-want-C-u-scroll t) | ||
130 | (setq evil-want-C-i-jump nil) | ||
131 | (setq evil-undo-system 'undo-tree) | ||
132 | :config | ||
133 | (evil-mode 1)) | ||
134 | |||
135 | (use-package evil-collection | ||
136 | :after evil | ||
137 | :config | ||
138 | (evil-collection-init)) | ||
139 | |||
140 | #+end_src | ||
141 | |||
142 | *** Keybinds | ||
143 | |||
144 | #+begin_src emacs-lisp | ||
145 | |||
146 | (jd/leader-key-def | ||
147 | "w" 'evil-window-map | ||
148 | "wd" '(evil-window-delete :which-key "Window delete")) | ||
149 | |||
150 | (jd/leader-key-def | ||
151 | "ou" '(undo-tree-visualize :which-key "Open")) | ||
152 | |||
153 | ;; remove . key | ||
154 | (define-key evil-normal-state-map (kbd ".") '()) | ||
155 | #+end_src | ||
156 | |||
157 | * UI Configuration | ||
158 | |||
159 | ** Basic UI setup | ||
160 | #+begin_src emacs-lisp | ||
161 | |||
162 | (setq inhibit-startup-message t) | ||
163 | (scroll-bar-mode -1) | ||
164 | (tool-bar-mode -1) | ||
165 | (tooltip-mode -1) | ||
166 | (menu-bar-mode -1) | ||
167 | (set-fringe-mode 10) | ||
168 | |||
169 | (set-face-attribute 'default nil :font "Hack" :height 100) | ||
170 | |||
171 | ; (load-theme 'wombat) | ||
172 | |||
173 | (global-set-key (kbd "<escape>") 'keyboard-escape-quit) | ||
174 | |||
175 | (use-package monokai-theme | ||
176 | :config | ||
177 | (load-theme 'monokai t)) | ||
178 | |||
179 | (use-package diminish) | ||
180 | |||
181 | #+end_src | ||
182 | |||
183 | ** Ivy and Counsel | ||
184 | |||
185 | #+begin_src emacs-lisp | ||
186 | |||
187 | (use-package counsel) | ||
188 | (use-package ivy | ||
189 | :diminish | ||
190 | :bind | ||
191 | (("C-s" . swiper) | ||
192 | :map ivy-minibuffer-map | ||
193 | ("C-k" . ivy-previous-line) | ||
194 | ("C-j" . ivy-next-line) | ||
195 | :map ivy-switch-buffer-map | ||
196 | ("C-k" . ivy-previous-line)) | ||
197 | :config | ||
198 | (ivy-mode 1)) | ||
199 | |||
200 | #+end_src | ||
201 | |||
202 | *** Keybinds | ||
203 | |||
204 | #+begin_src emacs-lisp | ||
205 | |||
206 | (jd/leader-key-def | ||
207 | "t" '(:ignore t :which-key "Toogle") | ||
208 | "tt" '(counsel-load-theme :which-key "Choose theme")) | ||
209 | |||
210 | (jd/leader-key-def | ||
211 | "bb" '(counsel-switch-buffer :which-key "Buffer switch") | ||
212 | "b" '(:ignore t :which-key "Buffer") | ||
213 | "," '(counsel-switch-buffer :which-key "Buffer switch")) | ||
214 | |||
215 | #+end_src | ||
216 | |||
217 | ** Which key | ||
218 | |||
219 | #+begin_src emacs-lisp | ||
220 | |||
221 | (use-package which-key | ||
222 | :diminish | ||
223 | :config | ||
224 | (which-key-mode) | ||
225 | (setq which-key-idle-delay 0.3)) | ||
226 | |||
227 | #+end_src | ||
228 | |||
229 | ** Modline | ||
230 | |||
231 | #+begin_src emacs-lisp | ||
232 | |||
233 | (use-package all-the-icons) | ||
234 | |||
235 | (use-package doom-modeline | ||
236 | :init (doom-modeline-mode 1) | ||
237 | :custom ((doom-modeline-height 15))) | ||
238 | |||
239 | #+end_src | ||
240 | |||
241 | ** Other Keybindings | ||
242 | *** Files | ||
243 | |||
244 | #+begin_src emacs-lisp | ||
245 | |||
246 | (jd/leader-key-def | ||
247 | "f" '(:ignore t :which-key "Files") | ||
248 | "fs" '(save-buffer :which-key "File save") | ||
249 | "." '(find-file :which-key "Find file") | ||
250 | "ff" '(find-file :which-key "Find file")) | ||
251 | |||
252 | #+end_src | ||
253 | |||
254 | *** Eval | ||
255 | |||
256 | #+begin_src emacs-lisp | ||
257 | |||
258 | (jd/leader-key-def | ||
259 | "e" '(:ignore t :which-key "Eval") | ||
260 | "eb" '(eval-buffer :which-key "Eval buffer")) | ||
261 | |||
262 | (jd/leader-key-def | ||
263 | :keymaps '(visual) | ||
264 | "er" '(eval-region :which-key "Eval region")) | ||
265 | |||
266 | #+end_src | ||
267 | |||
268 | *** Buffers | ||
269 | |||
270 | #+begin_src emacs-lisp | ||
271 | |||
272 | (jd/leader-key-def | ||
273 | "bk" '(kill-this-buffer :which-key "Buffer kill")) | ||
274 | |||
275 | #+end_src | ||
276 | |||
277 | * Org | ||
278 | |||
279 | ** Org-mode setup | ||
280 | |||
281 | #+begin_src emacs-lisp | ||
282 | |||
283 | (defun jd/org-mode-setup () | ||
284 | (org-indent-mode) | ||
285 | (variable-pitch-mode 1) | ||
286 | (visual-line-mode 1)) | ||
287 | |||
288 | (use-package org | ||
289 | :pin org | ||
290 | :commands (org-capture org-agenda) | ||
291 | :hook (org-mode . jd/org-mode-setup) | ||
292 | :config | ||
293 | (setq org-ellipsis " ▾") | ||
294 | |||
295 | (setq org-agenda-start-with-log-mode t) | ||
296 | (setq org-log-done 'time) | ||
297 | (setq org-log-into-drawer t) | ||
298 | (require 'org-tempo)) | ||
299 | |||
300 | #+end_src | ||
301 | |||
302 | *** Keybinds | ||
303 | |||
304 | #+begin_src emacs-lisp | ||
305 | |||
306 | (jd/leader-key-def | ||
307 | "o" '(:ignore t :which-key "Open") | ||
308 | "oa" '(org-agenda :which-key "Open org-agenda")) | ||
309 | |||
310 | #+end_src | ||
311 | |||
312 | ** Org make toc | ||
313 | |||
314 | #+begin_src emacs-lisp | ||
315 | (use-package org-make-toc) | ||
316 | |||
317 | (add-hook 'org-mode-hook #'org-make-toc-mode) | ||
318 | ; (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'org-make-toc))) | ||
319 | #+end_src | ||
320 | |||
321 | ** Org fonts | ||
322 | |||
323 | #+begin_src emacs-lisp | ||
324 | |||
325 | (defun jd/org-font-setup () | ||
326 | ;; Replace list hyphen with dot | ||
327 | (font-lock-add-keywords 'org-mode | ||
328 | '(("^ *\\([-]\\) " | ||
329 | (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•-")))))) | ||
330 | |||
331 | ;; Set faces for heading levels | ||
332 | (dolist (face '((org-level-1 . 1.3) | ||
333 | (org-level-2 . 1.2) | ||
334 | (org-level-3 . 1.1) | ||
335 | (org-level-4 . 1.0) | ||
336 | (org-level-5 . 1.1) | ||
337 | (org-level-6 . 1.1) | ||
338 | (org-level-7 . 1.1) | ||
339 | (org-level-8 . 1.1))) | ||
340 | (set-face-attribute (car face) nil :font "Monospace" :weight 'Bold :height (cdr face))) | ||
341 | |||
342 | ;; Ensure that anything that should be fixed-pitch in Org files appears that way | ||
343 | (set-face-attribute 'org-block nil :font "mononoki Nerd Font" :inherit 'fixed-pitch) | ||
344 | (set-face-attribute 'org-table nil :inherit 'fixed-pitch) | ||
345 | (set-face-attribute 'org-formula nil :inherit 'fixed-pitch) | ||
346 | (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch)) | ||
347 | (set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch)) | ||
348 | (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch)) | ||
349 | (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch)) | ||
350 | (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch)) | ||
351 | (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch) | ||
352 | (set-face-attribute 'line-number nil :inherit 'fixed-pitch) | ||
353 | (set-face-attribute 'line-number-current-line nil :inherit 'fixed-pitch)) | ||
354 | |||
355 | (with-eval-after-load 'org-faces (jd/org-font-setup)) | ||
356 | |||
357 | #+end_src | ||
358 | |||
359 | ** Org tempo setup | ||
360 | |||
361 | #+begin_src emacs-lisp | ||
362 | |||
363 | (defun jd/org-tempo-setup () | ||
364 | (add-to-list 'org-structure-template-alist '("sh" . "src sh")) | ||
365 | (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) | ||
366 | (add-to-list 'org-structure-template-alist '("li" . "src lisp")) | ||
367 | (add-to-list 'org-structure-template-alist '("sc" . "src scheme")) | ||
368 | (add-to-list 'org-structure-template-alist '("ts" . "src typescript")) | ||
369 | (add-to-list 'org-structure-template-alist '("py" . "src python")) | ||
370 | (add-to-list 'org-structure-template-alist '("go" . "src go")) | ||
371 | (add-to-list 'org-structure-template-alist '("yaml" . "src yaml"))) | ||
372 | |||
373 | (with-eval-after-load 'org-tempo (jd/org-tempo-setup)) | ||
374 | |||
375 | #+end_src | ||
376 | |||
377 | ** Org babel setup | ||
378 | |||
379 | *** Auto tangle | ||
380 | |||
381 | #+begin_src emacs-lisp | ||
382 | |||
383 | (defun jd/org-babel-tangle-config () | ||
384 | (when (string-equal (file-name-directory (buffer-file-name)) | ||
385 | (expand-file-name user-emacs-directory)) | ||
386 | ;; Dynamic scoping to the rescue | ||
387 | (let ((org-confirm-babel-evaluate nil)) | ||
388 | (org-babel-tangle)))) | ||
389 | |||
390 | (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'jd/org-babel-tangle-config))) | ||
391 | |||
392 | #+end_src | ||
393 | |||
394 | ** Org margin | ||
395 | |||
396 | #+begin_src emacs-lisp | ||
397 | |||
398 | (defun jd/org-mode-visual-fill () | ||
399 | (setq visual-fill-column-width 100 | ||
400 | visual-fill-column-center-text t) | ||
401 | (visual-fill-column-mode 1)) | ||
402 | |||
403 | (use-package visual-fill-column | ||
404 | :hook (org-mode . jd/org-mode-visual-fill)) | ||
405 | |||
406 | #+end_src | ||
407 | |||
408 | ** Org superstar | ||
409 | |||
410 | #+begin_src emacs-lisp | ||
411 | |||
412 | (use-package org-superstar | ||
413 | :hook (org-mode . org-superstar-mode) | ||
414 | :config | ||
415 | (setq org-superstar-special-todo-items t) | ||
416 | (setq org-superstar-remove-leading-stars t) | ||
417 | (setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●"))) | ||
418 | |||
419 | #+end_src | ||
420 | |||
421 | * Development | ||
422 | |||
423 | ** Projectile | ||
424 | |||
425 | #+begin_src emacs-lisp | ||
426 | |||
427 | (use-package projectile | ||
428 | :diminish projectile-mode | ||
429 | :init | ||
430 | (when (file-directory-p "~/Documents/code") | ||
431 | (setq projectile-project-search-path '("~/Documents/code/"))) | ||
432 | :config (projectile-mode) | ||
433 | :custom ((projectile-Completion-system 'ivy))) | ||
434 | |||
435 | #+end_src | ||
436 | |||
437 | *** Keybinds | ||
438 | |||
439 | #+begin_src emacs-lisp | ||
440 | |||
441 | (jd/leader-key-def | ||
442 | "p" '(projectile-command-map :which-key "Project") | ||
443 | "p <ESC>" '() | ||
444 | "SPC" '(projectile-find-file :which-key "Find file in project")) | ||
445 | |||
446 | #+end_src | ||
447 | |||
448 | ** Magit | ||
449 | |||
450 | #+begin_src emacs-lisp | ||
451 | |||
452 | (use-package magit | ||
453 | :custom | ||
454 | (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) | ||
455 | |||
456 | #+end_src | ||
457 | *** Keybinds | ||
458 | |||
459 | #+begin_src emacs-lisp | ||
460 | |||
461 | (jd/leader-key-def | ||
462 | "g" '(:ignore t :which-key "Git") | ||
463 | "gg" '(magit-status-here :which-key "Magit status")) | ||
464 | |||
465 | #+end_src | ||
466 | |||
467 | * Apps | ||
468 | |||
469 | ** Vterm | ||
470 | |||
471 | #+begin_src emacs-lisp | ||
472 | |||
473 | (use-package vterm) | ||
474 | (use-package vterm-toggle | ||
475 | :init | ||
476 | (setq vterm-toggle-fullscreen-p nil) | ||
477 | :config | ||
478 | (add-to-list 'display-buffer-alist | ||
479 | '((lambda (buffer-or-name _) | ||
480 | (let ((buffer (get-buffer buffer-or-name))) | ||
481 | (with-current-buffer buffer | ||
482 | (or (equal major-mode 'vterm-mode) | ||
483 | (string-prefix-p vterm-buffer-name (buffer-name buffer)))))) | ||
484 | (display-buffer-reuse-window display-buffer-at-bottom) | ||
485 | (reusable-frames . visible) | ||
486 | (window-height . 0.3)))) | ||
487 | |||
488 | #+end_src | ||
489 | |||
490 | *** Keybinds | ||
491 | |||
492 | #+begin_src emacs-lisp | ||
493 | |||
494 | (jd/leader-key-def | ||
495 | "oT" '(vterm :which-key "Open terminal in current window") | ||
496 | "ot" '(vterm-toggle :which-key "Toggle terminal")) | ||
497 | |||
498 | #+end_src | ||
499 | |||
500 | |||
501 | ** Dired | ||
502 | |||
503 | #+begin_src emacs-lisp | ||
504 | |||
505 | (use-package all-the-icons-dired | ||
506 | :hook (dired-mode . all-the-icons-dired-mode)) | ||
507 | |||
508 | (use-package dired-ranger) | ||
509 | |||
510 | (use-package dired | ||
511 | :ensure nil | ||
512 | :commands (dired dired-jump) | ||
513 | :bind (("C-x C-j" . dired-jump)) | ||
514 | :custom ((dired-listing-switches "-agho --group-directories-first")) | ||
515 | :config | ||
516 | (evil-collection-define-key 'normal 'dired-mode-map | ||
517 | "h" 'dired-up-directory | ||
518 | "l" 'dired-single-buffer)) | ||
519 | |||
520 | #+end_src | ||