From 801cd6dfd4fbed882095bec66e5335f3c154606a Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Wed, 21 Sep 2022 20:58:14 +0200 Subject: Update Emacs config --- Emacs.org | 319 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 270 insertions(+), 49 deletions(-) (limited to 'Emacs.org') diff --git a/Emacs.org b/Emacs.org index e531e89..3b24b1b 100644 --- a/Emacs.org +++ b/Emacs.org @@ -5,8 +5,9 @@ * Table of contents :toc: - [[#startup-performance][Startup Performance]] - [[#user-information-setup][User information setup]] -- [[#keep-clean][Keep clean]] +- [[#stay-clean][Stay clean]] - [[#package-setup][Package setup]] +- [[#update-path][Update Path]] - [[#keboard-setup][Keboard Setup]] - [[#general-setup][General Setup]] - [[#evil-mode-setup][Evil mode setup]] @@ -15,10 +16,12 @@ - [[#ivy-and-counsel][Ivy and Counsel]] - [[#which-key][Which key]] - [[#modline][Modline]] + - [[#hydra][Hydra]] - [[#beacon][Beacon]] - [[#other-keybindings][Other Keybindings]] - [[#org][Org]] - [[#org-mode-setup][Org-mode setup]] + - [[#org-evil][Org evil]] - [[#org-make-toc][Org make toc]] - [[#org-fonts][Org fonts]] - [[#org-tempo-setup][Org tempo setup]] @@ -37,6 +40,9 @@ - [[#vterm][Vterm]] - [[#dired][Dired]] - [[#emms][EMMS]] + - [[#pdf-tools][PDF Tools]] + - [[#mu4e][Mu4e]] +- [[#runtime-performance][Runtime Performance]] * Startup Performance @@ -102,6 +108,12 @@ #+end_src +* Update Path + +#+begin_src emacs-lisp + (push ".config/emacs/jd/" load-path) +#+end_src + * Keboard Setup ** General Setup @@ -134,9 +146,12 @@ (setq evil-want-integration t) (setq evil-want-keybinding nil) (setq evil-want-C-u-scroll t) - (setq evil-want-C-i-jump nil) + (setq evil-want-Y-yank-to-eol t) + (setq evil-want-C-i-jump nil) (setq evil-undo-system 'undo-tree) + (setq evil-kill-on-visual-paste nil) :config + (evil-set-initial-state 'exwm-mode 'emacs) (evil-mode 1)) (use-package evil-collection @@ -150,13 +165,21 @@ #+begin_src emacs-lisp + (defhydra hydra-resize-window (:timeout 4) + ("h" evil-window-decrease-width "<") + ("l" evil-window-increase-width ">") + ("k" evil-window-decrease-height "^") + ("j" evil-window-increase-height "v") + ("q" nil "finished" :exit t)) + (jd/leader-key-def "w" 'evil-window-map + "wr" '(hydra-resize-window/body :which-key "Rezize window") "wd" '(evil-window-delete :which-key "Window delete")) (jd/leader-key-def "ou" '(undo-tree-visualize :which-key "Open")) - + ;; remove . key (define-key evil-normal-state-map (kbd ".") '()) #+end_src @@ -182,7 +205,7 @@ (use-package doom-themes :config - (load-theme 'doom-molokai t)) + (load-theme 'doom-badger t)) (use-package diminish) @@ -205,24 +228,27 @@ #+begin_src emacs-lisp - (defun jd/switch-buffer () - (interactive) - (let ((completion-regexp-list '("\\`[^*]" - "\\`\\([^T]\\|T\\($\\|[^A]\\|A\\($\\|[^G]\\|G\\($\\|[^S]\\|S.\\)\\)\\)\\).*"))) - (call-interactively 'counsel-switch-buffer))) + (defun jd/switch-buffer () + (interactive) + (let ((completion-regexp-list '("\\`[^*]" + "\\`\\([^T]\\|T\\($\\|[^A]\\|A\\($\\|[^G]\\|G\\($\\|[^S]\\|S.\\)\\)\\)\\).*"))) + (call-interactively 'counsel-switch-buffer))) - (use-package counsel) - (use-package ivy - :diminish - :bind - (("C-s" . swiper) - :map ivy-minibuffer-map - ("C-k" . ivy-previous-line) - ("C-j" . ivy-next-line) - :map ivy-switch-buffer-map - ("C-k" . ivy-previous-line)) - :config - (ivy-mode 1)) + (use-package ivy + :diminish + :bind + (("C-s" . swiper) + :map ivy-minibuffer-map + ("C-k" . ivy-previous-line) + ("C-j" . ivy-next-line) + :map ivy-switch-buffer-map + ("C-k" . ivy-previous-line)) + :config + (ivy-mode 1)) + + (use-package counsel + :config + (counsel-mode 1)) #+end_src @@ -266,6 +292,41 @@ #+end_src +** Hydra + +#+begin_src emacs-lisp + + (use-package hydra + :defer t) + + (defun jd/text-scale-increase () + (interactive) + (let ((old-face-attribute (face-attribute 'default :height))) + (set-face-attribute 'default nil :height (+ old-face-attribute 10)))) + + (defun jd/text-scale-decrease () + (interactive) + (let ((old-face-attribute (face-attribute 'default :height))) + (set-face-attribute 'default nil :height (- old-face-attribute 10)))) + + (defhydra hydra-text-scale-global (:timeout 4) + "scale text" + ("j" jd/text-scale-increase "in") + ("k" jd/text-scale-decrease "out") + ("q" nil "finished" :exit t)) + + (defhydra hydra-text-scale (:timeout 4) + "scale text" + ("j" text-scale-increase "in") + ("k" text-scale-decrease "out") + ("q" nil "finished" :exit t)) + + (jd/leader-key-def + "tS" '(hydra-text-scale-global/body :which-key "Scale text") + "ts" '(hydra-text-scale/body :which-key "Scale text")) + +#+end_src + ** Beacon #+begin_src emacs-lisp @@ -333,14 +394,34 @@ :pin org :commands (org-capture org-agenda) :hook (org-mode . jd/org-mode-setup) - :init + :config + (setq org-directory (file-truename "~/Documents/org/")) + (setq org-mobile-inbox-for-pull (concat org-directory "flagged.org")) + (setq org-mobile-directory "~/Dropbox/Apps/MobileOrg") + (setq org-agenda-files + '("Tasks.org")) (setq org-ellipsis " ▾") (setq org-agenda-start-with-log-mode t) (setq org-log-done 'time) (setq org-log-into-drawer t) (setq org-return-follows-link t) - :config - (menu-bar--display-line-numbers-mode-none) + (setq org-capture-templates + `(("t" "Tasks / Projects") + ("tt" "Task" entry (file+olp "Tasks.org" "Inbox") + "* TODO %?\n %t\n %a\n %i" :empty-lines 1) + ("tT" "Task for tomorow" entry (file+olp "Tasks.org" "Inbox") + "* TODO %?\n %t\n SCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+1d\"))\n %a\n %i" :empty-lines 1) + + ("m" "Metrics Capture") + ("mm" "Metrics" table-line (file+headline "Metrics.org" "Metrics") + "| %U | %^{Weight} | %^{Waist} | %^{Notes} |" :kill-buffer t))) + + (setq org-latex-listings 'minted + org-latex-packages-alist '(("" "minted")) + org-latex-pdf-process + '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" + "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")) + (require 'org-tempo)) #+end_src @@ -350,11 +431,27 @@ #+begin_src emacs-lisp (jd/leader-key-def - "o" '(:ignore t :which-key "Open") + "o" '(:ignore t :which-key "Open/Org") + "oc" '(org-capture :which-key "Open org-capture") + "oop" '(org-mobile-pull :which-key "Org mobile pull") + "ooP" '(org-mobile-push :which-key "Org mobile push") "oa" '(org-agenda :which-key "Open org-agenda")) #+end_src +** Org evil + +#+begin_src emacs-lisp + + (use-package evil-org + :after org + :hook (org-mode . (lambda () evil-org-mode)) + :config + (require 'evil-org-agenda) + (evil-org-agenda-set-keys)) + +#+end_src + ** Org make toc #+begin_src emacs-lisp @@ -408,6 +505,8 @@ #+begin_src emacs-lisp (defun jd/org-tempo-setup () + (add-to-list 'org-structure-template-alist '("s" . "src")) + (add-to-list 'org-structure-template-alist '("sql" . "src sql")) (add-to-list 'org-structure-template-alist '("sh" . "src sh")) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) (add-to-list 'org-structure-template-alist '("li" . "src lisp")) @@ -423,6 +522,17 @@ ** Org babel setup +*** Load languages + +#+begin_src emacs-lisp + + (org-babel-do-load-languages + 'org-babel-load-languages + '((emacs-lisp . t) + (python . t))) + +#+end_src + *** Auto tangle #+begin_src emacs-lisp @@ -469,6 +579,20 @@ #+begin_src emacs-lisp + (defun jd/org-roam-filter-by-tag (tag-name) + (lambda (node) + (member tag-name (org-roam-node-tags node)))) + + (defun jd/org-roam-list-notes-by-tag (tag-name) + (mapcar #'org-roam-node-file + (seq-filter + (jd/org-roam-filter-by-tag tag-name) + (org-roam-node-list)))) + + (defun jd/org-roam-refreshagenda-list () + (interactive) + (setq org-agenda-files (org-roam-list-files))) + (use-package org-roam :custom (org-roam-directory (file-truename "~/Documents/org/roam/")) @@ -479,6 +603,8 @@ ("C-c n c" . org-roam-capture) ;; Dailies ("C-c n j" . org-roam-dailies-capture-today)) + :bind-keymap + ("C-c n d" . org-roam-dailies-map) :config ;; If you're using a vertical completion framework, you might want a more informative completion interface (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) @@ -519,11 +645,77 @@ (use-package python-mode :hook (python-mode . lsp-deferred) - :hook (python-mode . jd/python-mode-setup)) + :hook (python-mode . jd/python-mode-setup) + :config + (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))) (use-package pyvenv :after python-mode) + (use-package django-mode + :config + ;; Remove all django-mode objects from auto-mode-alist + (while (rassq 'django-mode auto-mode-alist) + (let ((django-mode-object (rassq 'django-mode auto-mode-alist))) + (setq auto-mode-alist (delete django-mode-object auto-mode-alist))))) + +#+end_src + +*** Java + +#+begin_src emacs-lisp + + (use-package lsp-java + :config (add-hook 'java-mode-hook 'lsp)) + +#+end_src + +*** Type Script + +#+begin_src emacs-lisp + + (use-package typescript-mode + :config + (setq typescript-indent-level 2) + (add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-mode))) + + (use-package tide + :ensure t + :after (typescript-mode company) + :hook ((typescript-mode . tide-setup) + (typescript-mode . tide-hl-identifier-mode))) + + (use-package flycheck + :ensure t + :hook ((after-init . global-flycheck-mode))) + +#+end_src + +*** Yaml + +#+begin_src emacs-lisp + + (use-package yaml-mode) + +#+end_src + +*** Docker + +#+begin_src emacs-lisp + + (use-package docker) + +#+end_src + +**** Keybinds + +#+begin_src emacs-lisp + + (jd/leader-key-def + "d" '(:ignore t :which-key "Docker") + "dc" '(docker-containers :which-key "Docker containers") + "dd" '(docker :which-key "Docker")) + #+end_src ** Dap mode @@ -554,19 +746,21 @@ #+begin_src emacs-lisp - (use-package company - :after lsp-mode - :hook (lsp-mode . company-mode) - :bind (:map company-active-map - ("" . company-complete-selection)) - (:map lsp-mode-map - ("" . company-indent-or-complete-common)) - :custom - (company-minimum-prefix-length 1) - (company-idle-delay 0.0)) + (use-package company + :after lsp-mode + :hook (lsp-mode . company-mode) + :bind (:map company-active-map + ("" . company-complete-selection)) + (:map lsp-mode-map + ("" . company-indent-or-complete-common)) + :custom + (company-minimum-prefix-length 1) + (company-idle-delay 0.0) + :config + (global-company-mode)) - (use-package company-box - :hook (company-mode . company-box-mode)) + (use-package company-box + :hook (company-mode . company-box-mode)) #+end_src @@ -659,20 +853,23 @@ #+end_src * Apps - ** Vterm #+begin_src emacs-lisp - (defun jd/open-new-vterm () + (defun jd/open-new-vterm (&optional jd/vterm-buffer-name) (interactive) (let ((buffer-name (generate-new-buffer-name vterm-buffer-name))) + (when jd/vterm-buffer-name + (setq buffer-name jd/vterm-buffer-name)) (switch-to-buffer buffer-name) (vterm-mode))) + (use-package vterm :config - (setq vterm-buffer-name "vterm")) + (setq vterm-buffer-name "vterm") + (evil-set-initial-state 'vterm-mode 'emacs)) #+end_src @@ -714,13 +911,37 @@ #+begin_src emacs-lisp - (use-package emms - :config - (require 'emms-setup) - (emms-all) - (emms-standard) - (emms-default-players) - (emms-mode-line-disable) - (emms-add-directory-tree "~/Documents/music/")) + (use-package emms + :config + (require 'emms-setup) + (emms-all) + (emms-standard) + (emms-default-players) + (emms-mode-line-disable) + ; (setq emms-info-functions '(emms-info-tinytag)) + (setq emms-browser-covers 'emms-browser-cache-thumbnail-async) + (setq emms-lyrics-dir "~/Documents/music/lyrics") + (emms-add-directory-tree "~/Documents/music/")) + +#+end_src +** PDF Tools + +#+begin_src emacs-lisp + + (use-package pdf-tools) + +#+end_src + +** Mu4e + +#+begin_src emacs-lisp + ;; Load my mu4e config + (require 'jd-mu4e) +#+end_src + +* Runtime Performance + +#+begin_src emacs-lisp + (setq gc-cons-threshold (* 2 1000 1000)) #+end_src -- cgit v1.2.3