summaryrefslogtreecommitdiffstats
path: root/Emacs.org
diff options
context:
space:
mode:
Diffstat (limited to 'Emacs.org')
-rw-r--r--Emacs.org1091
1 files changed, 0 insertions, 1091 deletions
diff --git a/Emacs.org b/Emacs.org
deleted file mode 100644
index 536aa85..0000000
--- a/Emacs.org
+++ /dev/null
@@ -1,1091 +0,0 @@
1#+author: jdlugosz963
2#+PROPERTY: header-args:emacs-lisp :tangle .config/emacs/init.el
3
4* Table of contents :toc:
5- [[#startup-performance][Startup Performance]]
6- [[#on-startup][On startup]]
7- [[#user-information-setup][User information setup]]
8- [[#stay-clean][Stay clean]]
9- [[#package-setup][Package setup]]
10- [[#keyboard-setup][Keyboard Setup]]
11 - [[#general-setup][General Setup]]
12 - [[#evil-mode-setup][Evil mode setup]]
13- [[#ui-configuration][UI Configuration]]
14 - [[#basic-ui-setup][Basic UI setup]]
15 - [[#hl-todo][Hl todo]]
16 - [[#ivy-and-counsel][Ivy and Counsel]]
17 - [[#which-key][Which key]]
18 - [[#modline][Modline]]
19 - [[#hydra][Hydra]]
20 - [[#beacon][Beacon]]
21 - [[#other-keybindings][Other Keybindings]]
22- [[#org][Org]]
23 - [[#org-mode-setup][Org-mode setup]]
24 - [[#org-evil][Org evil]]
25 - [[#org-make-toc][Org make toc]]
26 - [[#org-fonts][Org fonts]]
27 - [[#org-tempo-setup][Org tempo setup]]
28 - [[#org-babel-setup][Org babel setup]]
29 - [[#org-margin][Org margin]]
30 - [[#org-superstar][Org superstar]]
31 - [[#org-roam][Org roam]]
32 - [[#langtoolel][langtool.el]]
33- [[#development][Development]]
34 - [[#languages][Languages]]
35 - [[#company][Company]]
36 - [[#projectile][Projectile]]
37 - [[#neotree][Neotree]]
38 - [[#magit][Magit]]
39- [[#apps][Apps]]
40 - [[#vterm][Vterm]]
41 - [[#dired][Dired]]
42 - [[#emms][EMMS]]
43 - [[#pdf-tools][PDF Tools]]
44 - [[#mu4e][Mu4e]]
45 - [[#rss][RSS]]
46- [[#custom][Custom]]
47- [[#runtime-performance][Runtime Performance]]
48
49* Startup Performance
50
51#+begin_src emacs-lisp
52
53 (setq gc-cons-threshold (* 50 1000 1000))
54
55 (defun jd/display-startup-time ()
56 (message "Emacs loaded in %s with %d garbage collections."
57 (format "%.2f seconds"
58 (float-time
59 (time-subtract after-init-time before-init-time)))
60 gcs-done))
61
62#+end_src
63
64* On startup
65=jd/startup= function will be invoke after emacs startup
66
67#+begin_src emacs-lisp
68 (defun jd/startup ()
69 (electric-pair-mode 1)
70 (global-company-mode 1)
71 (jd/display-startup-time))
72
73 (add-hook 'emacs-startup-hook #'jd/startup)
74#+end_src
75
76* User information setup
77
78#+begin_src emacs-lisp
79
80 (setq user-full-name "Jakub Dlugosz"
81 user-mail-address "jdlugosz963@gmail.com")
82
83#+end_src
84
85* Stay clean
86
87#+begin_src emacs-lisp
88
89 (setq backup-directory-alist '(("." . "~/.cache/emacs/backup"))
90 backup-by-copying t
91 version-control t
92 delete-old-versions t
93 kept-new-versions 20
94 kept-old-versions 5)
95
96 (setq user-emacs-directory "~/.cache/emacs")
97
98#+end_src
99
100* Package setup
101
102#+begin_src emacs-lisp
103
104 (require 'package)
105 (setq package-archives '(("melpa" . "https://melpa.org/packages/")
106 ("org" . "https://orgmode.org/elpa/")
107 ("gnu-devel" . "https://elpa.gnu.org/devel/")
108 ("elpa" . "https://elpa.gnu.org/packages/")))
109 (package-initialize)
110
111 (unless package-archive-contents
112 (package-refresh-contents))
113
114 (unless (package-installed-p 'use-package)
115 (package-install 'use-package))
116
117 (setq use-package-always-ensure t)
118
119 (add-to-list 'load-path ".config/emacs/jd/")
120
121 (require 'use-package)
122
123#+end_src
124
125* Keyboard Setup
126** General Setup
127
128#+begin_src emacs-lisp
129
130 (use-package general
131 :config
132 (general-create-definer jd/leader-key-def
133 :keymaps '(normal insert visual emacs)
134 :prefix "SPC"
135 :global-prefix "C-SPC")
136
137 (general-create-definer jd/ctrl-c-keys
138 :prefix "C-c"))
139
140#+end_src
141
142** Evil mode setup
143
144#+begin_src emacs-lisp
145
146 (use-package undo-tree
147 :diminish
148 :config
149 (setq undo-tree-auto-save-history nil)
150 (global-undo-tree-mode 1))
151
152 (use-package evil
153 :init
154 (setq evil-want-integration t)
155 (setq evil-want-keybinding nil)
156 (setq evil-want-C-u-scroll t)
157 (setq evil-want-Y-yank-to-eol t)
158 (setq evil-want-C-i-jump nil)
159 (setq evil-undo-system 'undo-tree)
160 (setq evil-kill-on-visual-paste nil)
161 :config
162 (evil-set-initial-state 'exwm-mode 'emacs)
163 (evil-mode 1))
164
165 (use-package evil-collection
166 :after evil
167 :config
168 (evil-collection-init))
169
170#+end_src
171
172*Keybinds*
173
174#+begin_src emacs-lisp
175
176 (jd/leader-key-def
177 "w" 'evil-window-map
178 "wr" '(hydra-resize-window/body :which-key "Rezize window")
179 "wd" '(evil-window-delete :which-key "Window delete"))
180
181 (jd/leader-key-def
182 "ou" '(undo-tree-visualize :which-key "Open"))
183
184 ;; remove . key
185 (define-key evil-normal-state-map (kbd ".") '())
186#+end_src
187
188* UI Configuration
189** Basic UI setup
190#+begin_src emacs-lisp
191
192 (setq inhibit-startup-message t)
193 (setq visible-bell t)
194 (scroll-bar-mode -1)
195 (tool-bar-mode -1)
196 (tooltip-mode -1)
197 (menu-bar-mode -1)
198 (set-fringe-mode 10)
199
200 (set-face-attribute 'default nil :font "sourcecodepro" :height 100)
201
202 (add-hook 'prog-mode-hook 'menu-bar--display-line-numbers-mode-relative)
203
204 (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
205
206 (global-prettify-symbols-mode 1)
207
208 (defalias 'yes-or-no-p 'y-or-n-p)
209
210 (use-package doom-themes
211 :config
212 (load-theme 'doom-ayu-dark t))
213
214 (use-package diminish)
215
216#+end_src
217
218** Hl todo
219
220#+begin_src emacs-lisp
221
222 (use-package hl-todo
223 :init
224 (setq hl-todo-keyword-faces
225 '(("TODO" . "#FF0000")
226 ("FIXME" . "#FF0000")
227 ("DEBUG" . "#A020F0")))
228 :config
229 (global-hl-todo-mode 1))
230
231#+end_src
232
233** Ivy and Counsel
234
235#+begin_src emacs-lisp
236
237 (defun jd/switch-buffer ()
238 (interactive)
239 (let ((completion-regexp-list '("\\`[^*]"
240 "\\`\\([^T]\\|T\\($\\|[^A]\\|A\\($\\|[^G]\\|G\\($\\|[^S]\\|S.\\)\\)\\)\\).*")))
241 (call-interactively 'counsel-switch-buffer)))
242
243 (defvar jd/load-theme-hook nil)
244 (defun jd/load-theme ()
245 (interactive)
246 (counsel-load-theme)
247 (run-hooks 'jd/load-theme-hook))
248
249 (use-package ivy
250 :diminish
251 :bind
252 (("C-s" . swiper)
253 :map ivy-minibuffer-map
254 ("C-k" . ivy-previous-line)
255 ("C-j" . ivy-next-line)
256 :map ivy-switch-buffer-map
257 ("C-k" . ivy-previous-line))
258 :config
259 (ivy-mode 1))
260
261 (use-package counsel
262 :config
263 (counsel-mode 1))
264
265#+end_src
266
267*Keybinds*
268
269#+begin_src emacs-lisp
270
271 (jd/leader-key-def
272 "t" '(:ignore t :which-key "Toggle")
273 "tT" '(toggle-truncate-lines :which-key "Toggle truncate lines")
274 "tt" '(jd/load-theme :which-key "Choose theme"))
275
276 (jd/leader-key-def
277 "bb" '(jd/switch-buffer :which-key "Buffer switch")
278 "ba" '(counsel-switch-buffer :which-key "Buffer switch")
279 "b" '(:ignore t :which-key "Buffer")
280 "," '(counsel-switch-buffer :which-key "Buffer switch"))
281
282#+end_src
283
284** Which key
285
286#+begin_src emacs-lisp
287
288 (use-package which-key
289 :diminish
290 :config
291 (which-key-mode)
292 (setq which-key-idle-delay 0.3))
293
294#+end_src
295
296** Modline
297
298#+begin_src emacs-lisp
299
300 (use-package all-the-icons)
301
302 (use-package doom-modeline
303 :init (doom-modeline-mode 1)
304 :custom ((doom-modeline-height 15)))
305
306#+end_src
307
308** Hydra
309
310#+begin_src emacs-lisp
311
312 (use-package hydra
313 :defer t)
314
315 (defun jd/text-scale-increase ()
316 (interactive)
317 (let ((old-face-attribute (face-attribute 'default :height)))
318 (set-face-attribute 'default nil :height (+ old-face-attribute 10))))
319
320 (defun jd/text-scale-decrease ()
321 (interactive)
322 (let ((old-face-attribute (face-attribute 'default :height)))
323 (set-face-attribute 'default nil :height (- old-face-attribute 10))))
324
325 (defhydra hydra-resize-window (:timeout 4)
326 ("h" evil-window-decrease-width "<")
327 ("l" evil-window-increase-width ">")
328 ("k" evil-window-decrease-height "^")
329 ("j" evil-window-increase-height "v")
330 ("q" nil "finished" :exit t))
331
332 (defhydra hydra-text-scale-global (:timeout 4)
333 "scale text"
334 ("j" jd/text-scale-increase "in")
335 ("k" jd/text-scale-decrease "out")
336 ("q" nil "finished" :exit t))
337
338 (defhydra hydra-text-scale (:timeout 4)
339 "scale text"
340 ("j" text-scale-increase "in")
341 ("k" text-scale-decrease "out")
342 ("q" nil "finished" :exit t))
343
344 (jd/leader-key-def
345 "tS" '(hydra-text-scale-global/body :which-key "Scale text")
346 "ts" '(hydra-text-scale/body :which-key "Scale text"))
347
348#+end_src
349
350** Beacon
351
352#+begin_src emacs-lisp
353
354 (use-package beacon
355 :config
356 (beacon-mode 1))
357
358#+end_src
359
360** Other Keybindings
361*** Files
362
363#+begin_src emacs-lisp
364
365 (jd/leader-key-def
366 "f" '(:ignore t :which-key "Files")
367 "fs" '(save-buffer :which-key "File save")
368 "." '(find-file :which-key "Find file")
369 "ff" '(find-file :which-key "Find file"))
370
371#+end_src
372
373*** Eval
374
375#+begin_src emacs-lisp
376
377 (jd/leader-key-def
378 "e" '(:ignore t :which-key "Eval")
379 "eb" '(eval-buffer :which-key "Eval buffer")
380 "ee" '(eval-defun :which-key "Eval defun"))
381
382 (jd/leader-key-def
383 :keymaps '(visual)
384 "er" '(eval-region :which-key "Eval region"))
385
386#+end_src
387
388*** Buffers
389
390#+begin_src emacs-lisp
391
392 (defun jd/kill-other-buffers ()
393 (interactive)
394 (mapc 'kill-buffer (cdr (buffer-list (current-buffer)))))
395
396 (jd/leader-key-def
397 "bK" '(jd/kill-other-buffers :which-key "Kill other buffers")
398 "bk" '(kill-current-buffer :which-key "Kill buffer")
399 "bB" '(ibuffer :which-key "Open ibuffer"))
400
401#+end_src
402
403* Org
404** Org-mode setup
405
406*Define variables*
407
408#+begin_src emacs-lisp
409 (setq jd/org-home "~/Documents/Org")
410 (setq jd/org-roam-home (concat jd/org-home "/roam"))
411 (setq jd/org-roam-daily-home (concat jd/org-home "/roam/daily"))
412#+end_src
413
414#+begin_src emacs-lisp
415
416 (defun jd/org-mode-setup ()
417 (org-indent-mode)
418 (variable-pitch-mode 1)
419 (visual-line-mode 1))
420
421 (use-package org
422 :pin org
423 :commands (org-capture org-agenda)
424 :hook (org-mode . jd/org-mode-setup)
425 :config
426 (setq org-directory (file-truename "~/Documents/Org/"))
427 (setq org-mobile-inbox-for-pull (concat org-directory "flagged.org"))
428 (setq org-mobile-directory "~/Dropbox/Apps/MobileOrg")
429 (setq org-agenda-files
430 '("Tasks.org"))
431 (setq org-ellipsis " ▾")
432 (setq org-agenda-start-with-log-mode t)
433 (setq org-log-done 'time)
434 (setq org-log-into-drawer t)
435 (setq org-return-follows-link t)
436 (setq org-capture-templates
437 `(("t" "Tasks / Projects")
438 ("tt" "Task" entry (file+olp "Tasks.org" "Inbox")
439 "* TODO %?\n %t\n %a\n %i" :empty-lines 1)
440 ("tT" "Task for tomorow" entry (file+olp "Tasks.org" "Inbox")
441 "* TODO %?\n %t\n SCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+1d\"))\n %a\n %i" :empty-lines 1)
442
443 ("m" "Metrics Capture")
444 ("mm" "Metrics" table-line (file+headline "Metrics.org" "Metrics")
445 "| %U | %^{Weight} | %^{Waist} | %^{Notes} |" :kill-buffer t)))
446
447 (setq org-latex-listings 'minted
448 org-latex-packages-alist '(("" "minted"))
449 org-latex-pdf-process
450 '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
451 "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
452
453 (require 'org-tempo))
454
455#+end_src
456
457*Keybinds*
458
459#+begin_src emacs-lisp
460
461 (jd/leader-key-def
462 "o" '(:ignore t :which-key "Open/Org")
463 "oc" '(org-capture :which-key "Open org-capture")
464 "oop" '(org-mobile-pull :which-key "Org mobile pull")
465 "ooP" '(org-mobile-push :which-key "Org mobile push")
466 "oa" '(org-agenda :which-key "Open org-agenda"))
467
468#+end_src
469
470** Org evil
471
472#+begin_src emacs-lisp
473
474 (use-package evil-org
475 :after org
476 :hook (org-mode . (lambda () evil-org-mode))
477 :config
478 (require 'evil-org-agenda)
479 (evil-org-agenda-set-keys))
480
481#+end_src
482
483** Org make toc
484
485#+begin_src emacs-lisp
486
487 (use-package toc-org
488 :config
489 (add-hook 'org-mode-hook 'toc-org-mode))
490
491#+end_src
492
493** Org fonts
494
495#+begin_src emacs-lisp
496
497 (defun jd/org-font-setup ()
498 ;; Replace list hyphen with dot
499 (font-lock-add-keywords 'org-mode
500 '(("^ *\\([-]\\) "
501 (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•-"))))))
502
503 ;; Set faces for heading levels
504 (dolist (face '((org-level-1 . 1.3)
505 (org-level-2 . 1.2)
506 (org-level-3 . 1.1)
507 (org-level-4 . 1.0)
508 (org-level-5 . 1.1)
509 (org-level-6 . 1.1)
510 (org-level-7 . 1.1)
511 (org-level-8 . 1.1)))
512 (set-face-attribute (car face) nil :font "sans" :weight 'Bold :height (cdr face)))
513
514 ;; Ensure that anything that should be fixed-pitch in Org files appears that way
515 (set-face-attribute 'org-block nil :font "hack" :inherit 'fixed-pitch)
516 (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
517 (set-face-attribute 'org-formula nil :inherit 'fixed-pitch)
518 (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
519 (set-face-attribute 'org-table nil :font "hack ":inherit '(shadow fixed-pitch))
520 (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
521 (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
522 (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
523 (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
524 (set-face-attribute 'line-number nil :inherit 'fixed-pitch)
525 (set-face-attribute 'line-number-current-line nil :inherit 'fixed-pitch))
526
527 (with-eval-after-load 'org-faces (jd/org-font-setup))
528
529#+end_src
530
531** Org tempo setup
532
533#+begin_src emacs-lisp
534
535 (defun jd/org-tempo-setup ()
536 (add-to-list 'org-structure-template-alist '("s" . "src"))
537 (add-to-list 'org-structure-template-alist '("sql" . "src sql"))
538 (add-to-list 'org-structure-template-alist '("sh" . "src sh"))
539 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
540 (add-to-list 'org-structure-template-alist '("li" . "src lisp"))
541 (add-to-list 'org-structure-template-alist '("sc" . "src scheme"))
542 (add-to-list 'org-structure-template-alist '("ts" . "src typescript"))
543 (add-to-list 'org-structure-template-alist '("py" . "src python"))
544 (add-to-list 'org-structure-template-alist '("go" . "src go"))
545 (add-to-list 'org-structure-template-alist '("yaml" . "src yaml")))
546
547 (with-eval-after-load 'org-tempo (jd/org-tempo-setup))
548
549#+end_src
550
551** Org babel setup
552
553*** Load languages
554
555#+begin_src emacs-lisp
556
557 (org-babel-do-load-languages
558 'org-babel-load-languages
559 '((emacs-lisp . t)
560 (python . t)))
561
562#+end_src
563
564*** Auto tangle
565
566#+begin_src emacs-lisp
567
568 (defun jd/org-babel-tangle-config ()
569 (when (string-equal (file-name-directory (buffer-file-name))
570 (expand-file-name "~/dotfiles/"))
571 ;; Dynamic scoping to the rescue
572 (let ((org-confirm-babel-evaluate nil))
573 (org-babel-tangle))))
574
575 (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'jd/org-babel-tangle-config)))
576
577#+end_src
578
579** Org margin
580
581#+begin_src emacs-lisp
582
583 (defun jd/org-mode-visual-fill ()
584 (setq visual-fill-column-width 100
585 visual-fill-column-center-text t)
586 (visual-fill-column-mode 1))
587
588 (use-package visual-fill-column
589 :hook (org-mode . jd/org-mode-visual-fill))
590
591#+end_src
592
593** Org superstar
594
595#+begin_src emacs-lisp
596
597 (use-package org-superstar
598 :hook (org-mode . org-superstar-mode)
599 :init
600 (setq org-superstar-special-todo-items t)
601 (setq org-superstar-remove-leading-stars t)
602 (setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●")))
603
604#+end_src
605
606** Org roam
607
608#+begin_src emacs-lisp
609
610 (defun jd/org-roam-filter-by-tag (tag-name)
611 (lambda (node)
612 (member tag-name (org-roam-node-tags node))))
613
614 (defun jd/org-roam-list-notes-by-tag (tag-name)
615 (mapcar #'org-roam-node-file
616 (seq-filter
617 (jd/org-roam-filter-by-tag tag-name)
618 (org-roam-node-list))))
619
620 (defun jd/org-roam-refreshagenda-list ()
621 (interactive)
622 (setq org-agenda-files (org-roam-list-files)))
623
624 (use-package org-roam
625 :custom
626 (org-roam-directory (file-truename jd/org-roam-home))
627 :bind (("C-c n l" . org-roam-buffer-toggle)
628 ("C-c n f" . org-roam-node-find)
629 ("C-c n g" . org-roam-graph)
630 ("C-c n i" . org-roam-node-insert)
631 ("C-c n c" . org-roam-capture)
632 ;; Dailies
633 ("C-c n j" . org-roam-dailies-capture-today))
634 :bind-keymap
635 ("C-c n d" . org-roam-dailies-map)
636 :config
637 ;; If you're using a vertical completion framework, you might want a more informative completion interface
638 (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
639 (setq org-roam-capture-templates
640 '(("a" "workstuff" plain (file (concat org-roam-directory "/work"))
641 :target (file+head "work/%<%Y%m%d%H%M%S>-${slug}.org"
642 "#+title: ${title}\n") :unnarrowed t)
643 ("b" "research" plain (file "~/Documents/roam/study/templates/research.org")
644 :target (file+head "study/%<%Y%m%d%H%M%S>-${slug}.org"
645 "#+title: ${title}\n") :unnarrowed t)
646 ))
647
648 (org-roam-db-autosync-mode))
649
650#+end_src
651
652** langtool.el
653
654#+begin_src emacs-lisp
655
656 (use-package langtool
657 :config
658 (setq langtool-language-tool-jar "/home/jakub/Documents/LanguageTool-6.0/languagetool-commandline.jar")
659 (setq langtool-default-language "pl-PL"))
660
661 (jd/leader-key-def
662 "l" '(:ignore t :which-key "langtool")
663 "lc" 'langtool-check-buffer
664 "ld" 'langtool-check-done
665 "li" 'langtool-interactive-correction)
666
667
668#+end_src
669
670* Development
671** Languages
672
673*** C
674
675#+begin_src emacs-lisp
676
677 (setq c-default-style "linux"
678 c-basic-offset 8)
679
680 (setq gdb-many-windows t)
681
682#+end_src
683
684*** Lsp
685
686#+begin_src emacs-lisp
687
688 (use-package lsp-mode
689 :commands (lsp lsp-deferred)
690 :init
691 (setq lsp-headerline-breadcrumb-enable nil)
692 (setq lsp-diagnostics-provider :none)
693 (setq lsp-modeline-diagnostics-enable nil)
694 (setq lsp-keymap-prefix "C-c l")
695 :config
696 (lsp-enable-which-key-integration t))
697
698 (use-package lsp-ivy
699 :after lsp)
700
701#+end_src
702
703*** Lisp
704
705#+begin_src emacs-lisp
706
707 (use-package paredit)
708 (use-package evil-paredit)
709 (use-package rainbow-delimiters)
710
711 (defun jd/lisp-mode-setup ()
712 (rainbow-delimiters-mode)
713 (evil-paredit-mode)
714 (paredit-mode))
715
716 (add-hook 'emacs-startup-hook
717 (lambda ()
718 (add-hook 'scheme-mode-hook 'jd/lisp-mode-setup)
719 (add-hook 'emacs-lisp-mode-hook 'jd/lisp-mode-setup)
720 (add-hook 'lisp-mode-hook 'jd/lisp-mode-setup)))
721
722 (evil-define-key 'normal paredit-mode-map (kbd "g h") 'paredit-forward-barf-sexp)
723 (evil-define-key 'normal paredit-mode-map (kbd "g l") 'paredit-forward-slurp-sexp)
724
725 (evil-define-key 'normal paredit-mode-map (kbd "g H") 'paredit-backward-slurp-sexp)
726 (evil-define-key 'normal paredit-mode-map (kbd "g L") 'paredit-backward-barf-sexp)
727
728 (use-package geiser)
729 (use-package geiser-guile)
730
731#+end_src
732
733*** Python
734
735#+begin_src emacs-lisp
736
737 (defun jd/python-mode-setup ()
738 (let ((project-venv-path (concat (projectile-project-root) "venv/")))
739 (when (projectile--directory-p project-venv-path)
740 (pyvenv-activate project-venv-path)
741 (pyvenv-mode))))
742
743 ;; (use-package python-mode ;;TODO: find alternative
744 ;; :hook (python-mode . lsp-deferred)
745 ;; :hook (python-mode . jd/python-mode-setup)
746 ;; :config
747 ;; (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)))
748
749 (use-package pyvenv
750 :after python-mode)
751
752#+end_src
753
754*** TypeScript
755
756#+begin_src emacs-lisp
757
758 (use-package typescript-mode
759 :mode ("\\.ts\\'")
760 :config
761 (setq typescript-indent-level 2))
762
763 (defun jd/activate-tide-mode ()
764 (when (and (stringp buffer-file-name)
765 (string-match "\\.[tj]sx?\\'" buffer-file-name))
766 (tide-setup)
767 (tide-hl-identifier-mode)))
768
769 (use-package tide
770 :after (typescript-mode company web-mode))
771
772 (use-package flycheck
773 :hook ((after-init . global-flycheck-mode)))
774
775 (use-package web-mode
776 :hook ((web-mode . jd/activate-tide-mode))
777 :mode
778 ("\\.ejs\\'" "\\.hbs\\'" "\\.html\\'" "\\.php\\'" "\\.[jt]sx?\\'")
779 :config
780 (setq web-mode-content-types-alist '(("jsx" . "\\.[jt]sx?\\'")))
781 (setq web-mode-markup-indent-offset 2)
782 (setq web-mode-css-indent-offset 2)
783 (setq web-mode-code-indent-offset 2)
784 (setq web-mode-script-padding 2)
785 (setq web-mode-block-padding 2)
786 (setq web-mode-style-padding 2)
787 (setq web-mode-enable-auto-pairing t)
788 (setq web-mode-enable-auto-closing t)
789 (setq web-mode-enable-current-element-highlight t))
790
791#+end_src
792
793*** Yaml
794
795#+begin_src emacs-lisp
796
797 (use-package yaml-mode)
798
799#+end_src
800
801*** Docker
802
803#+begin_src emacs-lisp
804
805 (use-package docker)
806
807#+end_src
808
809*Keybinds*
810
811#+begin_src emacs-lisp
812
813 (jd/leader-key-def
814 "d" '(:ignore t :which-key "Docker")
815 "dc" '(docker-containers :which-key "Docker containers")
816 "dd" '(docker :which-key "Docker"))
817
818#+end_src
819
820** Company
821
822#+begin_src emacs-lisp
823
824 (use-package company
825 :after lsp-mode
826 :hook (lsp-mode . company-mode)
827 :bind (:map company-active-map
828 ("<tab>" . company-complete-selection))
829 (:map lsp-mode-map
830 ("<tab>" . company-indent-or-complete-common))
831 :custom
832 (company-minimum-prefix-length 1)
833 (company-idle-delay 0.0)
834 :config
835 (global-company-mode))
836
837 (use-package company-box
838 :hook (company-mode . company-box-mode))
839
840#+end_src
841
842** Projectile
843
844#+begin_src emacs-lisp
845
846 (use-package projectile
847 :diminish projectile-mode
848 :init
849 (when (file-directory-p "~/Documents/code")
850 (setq projectile-project-search-path '("~/Documents/code/")))
851 :custom ((projectile-Completion-system 'ivy))
852 :config
853 (setq projectile-switch-project-action #'projectile-dired)
854 (projectile-mode))
855
856#+end_src
857
858*Keybinds*
859
860#+begin_src emacs-lisp
861
862 (jd/leader-key-def
863 "p" '(projectile-command-map :which-key "Project")
864 "p <ESC>" '()
865 "SPC" '(projectile-find-file :which-key "Find file in project"))
866
867#+end_src
868
869** Neotree
870
871#+begin_src emacs-lisp
872
873 (defun jd/neotree-project-dir ()
874 "Open NeoTree using the git root."
875 (interactive)
876 (let ((project-dir (projectile-project-root))
877 (file-name (buffer-file-name)))
878 (neotree-toggle)
879 (if project-dir
880 (if (neo-global--window-exists-p)
881 (progn
882 (neotree-dir project-dir)
883 (neotree-find file-name)))
884 (message "Could not find git project root."))))
885
886 (use-package neotree
887 :init
888 (setq neo-theme 'icons)
889 :config
890
891 (evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter)
892 (evil-define-key 'normal neotree-mode-map (kbd "C-RET") 'neotree-quick-look)
893 (evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide)
894 (evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter)
895 (evil-define-key 'normal neotree-mode-map (kbd "g") 'neotree-refresh)
896 (evil-define-key 'normal neotree-mode-map (kbd "A") 'neotree-stretch-toggle)
897 (evil-define-key 'normal neotree-mode-map (kbd "H") 'neotree-hidden-file-toggle))
898
899#+end_src
900
901*Keybinds*
902
903#+begin_src emacs-lisp
904
905 (jd/leader-key-def
906 "op" '(jd/neotree-project-dir :which-key "Open neotree"))
907
908#+end_src
909
910** Magit
911
912#+begin_src emacs-lisp
913
914 (use-package magit
915 :custom
916 (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
917
918#+end_src
919
920*Keybinds*
921
922#+begin_src emacs-lisp
923
924 (jd/leader-key-def
925 "g" '(:ignore t :which-key "Git")
926 "gg" '(magit-status-here :which-key "Magit status"))
927
928#+end_src
929
930* Apps
931** Vterm
932
933#+begin_src emacs-lisp
934
935 (defun jd/open-new-vterm (&optional jd/vterm-buffer-name)
936 (interactive)
937 (let ((buffer-name (generate-new-buffer-name vterm-buffer-name)))
938 (when jd/vterm-buffer-name
939 (setq buffer-name jd/vterm-buffer-name))
940 (switch-to-buffer buffer-name)
941 (vterm-mode)))
942
943
944 (use-package vterm
945 :init
946 (add-to-list 'project-switch-commands '(project-vterm "Vterm") t)
947 (add-to-list 'project-kill-buffer-conditions '(major-mode . vterm-mode))
948 (setq vterm-copy-exclude-prompt t)
949 :config
950 (setq vterm-buffer-name "vterm")
951 (evil-set-initial-state 'vterm-mode 'emacs)
952 (setq vterm-tramp-shells (append '(("ssh" "/bin/bash")) vterm-tramp-shells)))
953
954#+end_src
955
956*Keybinds*
957
958#+begin_src emacs-lisp
959
960 (jd/leader-key-def
961 "ot" '(jd/open-new-vterm :which-key "Open terminal in current window"))
962
963#+end_src
964
965** Dired
966
967#+begin_src emacs-lisp
968
969 (use-package all-the-icons-dired
970 :hook (dired-mode . all-the-icons-dired-mode))
971
972 (use-package dired-ranger)
973
974 (use-package dired
975 :ensure nil
976 :commands (dired dired-jump)
977 :custom ((dired-listing-switches "-agho --group-directories-first"))
978 :config
979 (evil-collection-define-key 'normal 'dired-mode-map
980 "y" 'dired-ranger-copy
981 "p" 'dired-ranger-paste
982 "X" 'dired-ranger-move
983 "h" 'dired-up-directory
984 "t" 'dired-create-empty-file
985 "T" 'dired-toggle-marks
986 "l" 'dired-find-file)
987 (setq dired-kill-when-opening-new-dired-buffer t)
988 (evil-define-key 'normal dired-mode-map (kbd "q") 'kill-current-buffer))
989
990
991#+end_src
992
993** EMMS
994
995#+begin_src emacs-lisp
996
997 (use-package emms
998 :config
999 (require 'emms-setup)
1000 (emms-all)
1001 (emms-standard)
1002 (emms-default-players)
1003 (emms-mode-line-disable)
1004 ; (setq emms-info-functions '(emms-info-tinytag))
1005 (setq emms-browser-covers 'emms-browser-cache-thumbnail-async)
1006 ;; (setq emms-lyrics-dir "~/Documents/music/lyrics")
1007 (emms-add-directory-tree "~/Documents/Music/"))
1008
1009#+end_src
1010
1011** PDF Tools
1012
1013#+begin_src emacs-lisp
1014
1015 (use-package pdf-tools)
1016
1017#+end_src
1018
1019** Mu4e
1020- Load my [[./Mail.org][mu4e]] config
1021
1022#+begin_src emacs-lisp
1023 (require 'jd-mu4e)
1024#+end_src
1025
1026** RSS
1027
1028#+begin_src emacs-lisp
1029
1030 (use-package elfeed
1031 :config
1032 (setq elfeed-feeds
1033 '(("https://www.reddit.com/r/emacs.rss" emacs)
1034 ("https://www.reddit.com/r/gnu.rss" gnu)
1035 ("https://stallman.org/rss/rss.xml" stallman))))
1036
1037#+end_src
1038
1039* Custom
1040
1041#+begin_src emacs-lisp
1042 (defun jd/generete-qr-from-clipboard ()
1043 (interactive)
1044 (let ((clipboard-value (x-get-clipboard))
1045 (clipboard-file-path "/tmp/clipboard_value.txt")
1046 (clipboard-out-image "/tmp/qr.png"))
1047 (with-temp-file clipboard-file-path
1048 (insert clipboard-value))
1049 (shell-command (concat
1050 "qrencode -o "
1051 clipboard-out-image
1052 " < "
1053 clipboard-file-path))
1054 (find-file clipboard-out-image)))
1055
1056
1057 ;; (defun jd/screenshot ()
1058 ;; (inactive)
1059 ;; (let* ((screenshot-command '("import" "png:-"))
1060 ;; (image
1061 ;; (with-temp-buffer
1062 ;; (set-buffer-multibyte nil)
1063 ;; (apply #'call-process
1064 ;; (car screenshot-command) nil (current-buffer) nil
1065 ;; (cdr screenshot-command))
1066 ;; (buffer-string))))
1067 ;; (set-mark (point))
1068 ;; (insert-image
1069 ;; (create-image image 'png t
1070 ;; :max-width (truncate (* (frame-pixel-width) 0.8))
1071 ;; :max-height (truncate (* (frame-pixel-height) 0.8))
1072 ;; :scale 1)
1073 ;; (format "<#part type=\"image/png\" disposition=inline data-encoding=base64 raw=t>\n%s\n<#/part>"
1074 ;; ;; Get a base64 version of the image -- this avoids later
1075 ;; ;; complications if we're auto-saving the buffer and
1076 ;; ;; restoring from a file.
1077 ;; (with-temp-buffer
1078 ;; (set-buffer-multibyte nil)
1079 ;; (insert image)
1080 ;; (base64-encode-region (point-min) (point-max) t)
1081 ;; (buffer-string))))
1082 ;; (insert "\n\n")
1083 ;; (message "")))
1084
1085#+end_src
1086
1087* Runtime Performance
1088
1089#+begin_src emacs-lisp
1090 (setq gc-cons-threshold (* 2 1000 1000))
1091#+end_src