Refactor doom config

This commit is contained in:
agryphus 2024-02-20 22:11:48 -05:00
parent 11887d795a
commit ac53b563f2
2 changed files with 411 additions and 507 deletions

View file

@ -7,208 +7,346 @@
# Show toc up to two headers # Show toc up to two headers
#+OPTIONS: toc:2 #+OPTIONS: toc:2
* TABLE OF CONTENTS :toc: * TABLE OF CONTENTS :toc_3:
- [[#general-keybinds][General Keybinds]]
- [[#quick-find-files][Quick Find Files]] - [[#quick-find-files][Quick Find Files]]
- [[#elisp-evaluation][Elisp Evaluation]]
- [[#unsetting-bindings-that-step-on-mine][Unsetting Bindings That Step on Mine]]
- [[#better-defaults][Better Defaults]]
- [[#disable-really-quit-emacs-prompt][Disable "Really Quit Emacs" Prompt]]
- [[#relative-line-numbers][Relative Line Numbers]]
- [[#scrolloff][Scrolloff]]
- [[#scratch-buffer-mode][Scratch Buffer Mode]]
- [[#evil][Evil]]
- [[#changing-keybinds][Changing Keybinds]]
- [[#leave-insertvisual-modes-with-c-c][Leave insert/visual modes with C-C]]
- [[#clearing-highlight-with-c-l][Clearing highlight with C-L]]
- [[#swap-gkj-and-kj][Swap g[k/j] and k/j]]
- [[#resize-font-in-insert-mode][Resize Font in Insert Mode]]
- [[#visual-tweaks][Visual Tweaks]]
- [[#scale-line-number-size-with-buffer-text][Scale Line Number Size with Buffer Text]]
- [[#block-cursor-not-showing-in-terminal-mode][Block Cursor Not Showing in Terminal Mode]]
- [[#doom-dashboard-spacing][Doom Dashboard Spacing]]
- [[#posframe][Posframe]]
- [[#vertico-posframe][Vertico Posframe]]
- [[#company-posframe][Company Posframe]]
- [[#fonts][Fonts]]
- [[#default][Default]]
- [[#mixed-pitch-mode][Mixed Pitch Mode]]
- [[#coloring][Coloring]]
- [[#themes][Themes]]
- [[#languages][Languages]]
- [[#lspcompletion-config][LSP/Completion Config]]
- [[#company-mode][Company-mode]]
- [[#make-lsp-ui-sideline-suggestions-the-same-size-as-buffer-text][Make lsp-ui sideline suggestions the same size as buffer text]]
- [[#lsp-mode-in-org-src-blocks][LSP mode in org src blocks]]
- [[#org][Org]] - [[#org][Org]]
- [[#org-whiteroom][Org Whiteroom]] - [[#org-modern][Org Modern]]
- [[#special-symbolscharacters][Special symbols/characters]] - [[#special-symbolscharacters][Special symbols/characters]]
- [[#agenda][Agenda]] - [[#agenda][Agenda]]
- [[#svg-tags][SVG Tags]] - [[#svg-tags][SVG Tags]]
- [[#vterm][Vterm]]
- [[#languages][Languages]]
- [[#lspcompletion-config][LSP/Completion Config]]
- [[#python][Python]]
- [[#typst][Typst]]
- [[#shell][Shell]] - [[#shell][Shell]]
- [[#nix][Nix]] - [[#nix][Nix]]
- [[#tweaksfixes][Tweaks/Fixes]] - [[#miscellaneous][Miscellaneous]]
- [[#scale-line-number-size-with-buffer-text][Scale line number size with buffer text]] - [[#anki][Anki]]
- [[#block-cursor-not-showing-up-in-terminal-mode][Block cursor not showing up in terminal mode]] - [[#face-explorer][Face Explorer]]
- [[#disable-really-quit-emacs-prompt][Disable "Really Quit Emacs" Prompt]]
- [[#relative-line-numbers][Relative Line Numbers]]
- [[#doom-dashboard][Doom Dashboard]]
- [[#vertico][Vertico]]
- [[#scrolloff][Scrolloff]]
- [[#scratch-buffer-mode][Scratch Buffer Mode]]
- [[#unsetting-bindings-that-step-on-mine][Unsetting bindings that step on mine]]
- [[#evil][Evil]]
- [[#leave-insertvisual-modes-with-c-c][Leave insert/visual modes with C-C]]
- [[#clearing-highlight-with-c-l][Clearing highlight with C-L]]
- [[#resize-font-in-insert-mode][Resize font in insert mode]]
- [[#swap-gkj-and-kj][Swap g[k/j] and k/j]]
- [[#fonts][Fonts]]
- [[#elisp-evaluation][Elisp Evaluation]]
- [[#coloring][Coloring]]
* Quick Find Files * General Keybinds
** Quick Find Files
#+begin_src emacs-lisp #+begin_src emacs-lisp
(map! :leader (map! :leader
(:prefix ("=" . "open file") (:prefix ("=" . "open file")
:desc "Edit doom config.org" "c" #'(lambda () (interactive) (find-file "~/.config/doom/config.org")) :desc "Edit doom config.org" "c" #'(lambda () (interactive) (find-file "~/.config/doom/config.org"))
:desc "Edit doom init.el" "i" #'(lambda () (interactive) (find-file "~/.config/doom/init.el")) :desc "Edit doom init.el" "i" #'(lambda () (interactive) (find-file "~/.config/doom/init.el"))))
:desc "Edit doom packages.el" "p" #'(lambda () (interactive) (find-file "~/.config/doom/packages.el"))))
(map! "C-/" #'comment-line) (map! "C-/" #'comment-line)
#+end_src #+end_src
* Org ** Elisp Evaluation
** Org Whiteroom
#+begin_src emacs-lisp #+begin_src emacs-lisp
(add-hook 'org-mode-hook 'mixed-pitch-mode) (map! :leader
(:prefix ("e". "evaluate")
:desc "Evaluate elisp in buffer" "b" #'eval-buffer
:desc "Evaluate defun" "d" #'eval-defun
:desc "Evaluate elisp expression" "e" #'eval-expression
:desc "Evaluate last sexpression" "l" #'eval-last-sexp
:desc "Evaluate elisp in region" "r" #'eval-region))
#+end_src
** Unsetting Bindings That Step on Mine
#+begin_src emacs-lisp
(after! ccls! (unbind-key "M-a" c-mode-base-map))
;; The C package adds a keybind to (ccls-navigate "D"), which not
;; only steps on my binding, but is not even a provided function.
(map! :after ccls
:map (c-mode-map c++-mode-map)
:n "C-h" nil
:n "C-j" nil
:n "C-k" nil
:n "C-l" nil)
#+end_src
* Better Defaults
** Disable "Really Quit Emacs" Prompt
#+begin_src emacs-lisp
(setq confirm-kill-emacs nil)
#+end_src
** Relative Line Numbers
#+begin_src emacs-lisp
(setq display-line-numbers-type 'relative)
#+end_src
** Scrolloff
#+begin_src emacs-lisp
(setq ag/scroll-margin 8) ;; Custom var
(setq scroll-margin ag/scroll-margin)
;; Exceptions for modes that need 0 scroll margin
(add-hook 'eat-mode-hook (lambda () (setq-local scroll-margin 0)))
(add-hook 'eat-exit-hook (lambda () (setq-local scroll-margin ag/scroll-margin)))
(add-hook '+doom-dashboard-mode-hook (lambda () (setq-local scroll-margin 0)))
#+end_src
** Scratch Buffer Mode
Scratch buffer is, by default, in interactive lisp mode. Default to just plaintext.
#+begin_src emacs-lisp
(setq initial-major-mode 'text-mode)
#+end_src
* Evil
** Changing Keybinds
*** Leave insert/visual modes with C-C
#+begin_src emacs-lisp
(define-key evil-insert-state-map (kbd "C-c") 'evil-normal-state)
(define-key evil-visual-state-map (kbd "C-c") 'evil-normal-state)
#+end_src
*** Clearing highlight with C-L
Mimics the "redraw" signal sent to terminals for vim.
#+begin_src emacs-lisp
(define-key evil-normal-state-map (kbd "C-l") 'evil-ex-nohighlight)
#+end_src
*** Swap g[k/j] and k/j
#+begin_src emacs-lisp
(define-key evil-motion-state-map (kbd "gj") 'evil-next-line)
(define-key evil-motion-state-map (kbd "gk") 'evil-previous-line)
(define-key evil-motion-state-map (kbd "j") 'evil-next-visual-line)
(define-key evil-motion-state-map (kbd "k") 'evil-previous-visual-line)
#+end_src
** Resize Font in Insert Mode
These are the same keybinds that are able to work outside of insert mode.
#+begin_src emacs-lisp
(define-key evil-insert-state-map (kbd "C-M-=") 'doom/increase-font-size)
(define-key evil-insert-state-map (kbd "C-M--") 'doom/decrease-font-size)
(define-key evil-insert-state-map (kbd "C-=") 'text-scale-increase)
(define-key evil-insert-state-map (kbd "C--") 'text-scale-decrease)
#+end_src
* Visual Tweaks
** Scale Line Number Size with Buffer Text
#+begin_src emacs-lisp
(add-hook 'text-scale-mode-hook (lambda() (face-remap--remap-face 'line-number)))
(add-hook 'text-scale-mode-hook (lambda() (face-remap--remap-face 'line-number-current-line)))
#+end_src
** Block Cursor Not Showing in Terminal Mode
#+begin_src emacs-lisp :tangle packages.el
(package! evil-terminal-cursor-changer)
#+end_src #+end_src
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-src-fontify-natively t) (use-package! evil-terminal-cursor-changer
:hook (tty-setup . evil-terminal-cursor-changer-activate))
#+end_src #+end_src
** Special symbols/characters ** Doom Dashboard Spacing
I felt that the spacing between the line items in the graphical doom dashboard was too large. There did not seem to be any variable to set this, so I overrode the entire function and manually decreased the spacing
#+begin_src emacs-lisp #+begin_src emacs-lisp
(after! org (defun doom-dashboard-widget-shortmenu ()
(setq (insert "\n")
org-superstar-headline-bullets-list '("⁖" "◉" "●" "○" "◉" "●" "○" "◉" "●" "○") (dolist (section +doom-dashboard-menu-sections)
org-superstar-itembullet-alist '((?+ . ?➤) (?- . ?✦)))) ; changes +/- symbols in item lists (cl-destructuring-bind (label &key icon action when face key) section
(when (and (fboundp action)
(or (null when)
(eval when t)))
(insert
(+doom-dashboard--center
(- +doom-dashboard--width 1)
(let ((icon (if (stringp icon) icon (eval icon t))))
(format (format "%s%%s%%-10s" (if icon "%3s\t" "%3s"))
(or icon "")
(with-temp-buffer
(insert-text-button
label
'action
`(lambda (_)
(call-interactively (or (command-remapping #',action)
#',action)))
'face (or face 'doom-dashboard-menu-title)
'follow-link t
'help-echo
(format "%s (%s)" label
(propertize (symbol-name action) 'face 'doom-dashboard-menu-desc)))
(format "%-37s" (buffer-string)))
;; Lookup command keys dynamically
(propertize
(or key
(when-let*
((keymaps
(delq
nil (list (when (bound-and-true-p evil-local-mode)
(evil-get-auxiliary-keymap +doom-dashboard-mode-map 'normal))
+doom-dashboard-mode-map)))
(key
(or (when keymaps
(where-is-internal action keymaps t))
(where-is-internal action nil t))))
(with-temp-buffer
(save-excursion (insert (key-description key)))
(while (re-search-forward "<\\([^>]+\\)>" nil t)
(let ((str (match-string 1)))
(replace-match
(upcase (if (< (length str) 3)
str
(substring str 0 3))))))
(buffer-string)))
"")
'face 'doom-dashboard-menu-desc))))
;; (if (display-graphic-p)
;; "\n\n"
;; "\n"))))))
"\n"))))) ;; Overwrote above lines so remove the extra newline in graphical mode from the doom dashboard
(defun ag/prettify-me () (remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-footer) ;; No github at bottom
(setq prettify-symbols-alist
'(("TODO" . "")
("WAIT" . "")
("NOPE" . "")
("DONE" . "")
("[ ]" . "")
("[X]" . "")
("[-]" . "")
("#+begin_src" . "")
("#+BEGIN_SRC" . "")
("#+end_src" . "")
("#+END_SRC" . "")
(":properties:" . "")
(":PROPERTIES:" . "")
("#+property:" . "")
("#+PROPERTY:" . "")
(":end:" . "―")
(":END:" . "―")
("#+options:" . "")
("#+OPTIONS:" . "")
("#+startup:" . "")
("#+STARTUP:" . "")
("#+title: " . "")
("#+TITLE: " . "")
("#+TOC:" . "󰠶")
("#+toc:" . "󰠶")
("#+results:" . "")
("#+RESULTS:" . "")
("#+name:" . "")
("#+NAME:" . "")
("#+roam_tags:" . "")
("#+ROAM_TAGS:" . "")
("#+filetags:" . "")
("#+FILETAGS:" . "")
("#+html_head:" . "")
("#+HTML_HEAD:" . "")
("#+subtitle:" . "")
("#+SUBTITLE:" . "")
("#+author:" . "󰙏")
("#+AUTHOR:" . "󰙏")
(":effort:" . "")
(":EFFORT:" . "")
("scheduled:" . "")
("SCHEDULED:" . "")
("deadline:" . "")
("DEADLINE:" . ""))))
(add-hook 'org-mode-hook 'ag/prettify-me)
;; Can probably remove duplicates with
;; (mapcan (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
#+end_src #+end_src
** Agenda ** Posframe
#+begin_src emacs-lisp *** Vertico Posframe
(setq org-agenda-files #+begin_src emacs-lisp :tangle packages.el
'("~/.local/share/org-agenda")) (package! vertico-posframe)
(map! :leader :desc "Open org calendar" "o c" #'cfw:open-org-calendar)
(add-hook 'calendar-after-frame-setup-hook 'cfw:refresh-calendar-buffer)
#+end_src #+end_src
** SVG Tags
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package! svg-tag-mode) (vertico-posframe-mode 1)
(setq svg-tag-tags (setq vertico-multiform-commands
'((":TODO:" . ((lambda (tag) (svg-tag-make "TODO")))) '((consult-line
("[X]" . ((lambda (tag) (svg-tag-make "X")))))) posframe
(vertico-posframe-poshandler . posframe-poshandler-frame-top-center)
(vertico-posframe-border-width . 10)
;; NOTE: This is useful when emacs is used in both in X and
;; terminal, for posframe do not work well in terminal, so
;; vertico-buffer-mode will be used as fallback at the
;; moment.
(vertico-posframe-fallback-mode . vertico-buffer-mode))
(t posframe)))
(vertico-multiform-mode 1)
#+end_src #+end_src
* Vterm *** Company Posframe
#+begin_src emacs-lisp Company mode, by default, has its suggestions snap to the grid. When using anything other than monospaced font, this creately very glitchy looking behavior. Popping it out in a posframe makes the suggestions exist in their own graphical window.
(use-package! vterm #+begin_src emacs-lisp :tangle packages.el
:config (package! company-posframe)
(setq vterm-timer-delay 0.01))
(map! :after vterm
:map vterm-mode-map
;; Send special keys to vterm
:ni "C-c" #'vterm--self-insert
:ni "C-x" #'vterm--self-insert
:ni [escape] #'vterm--self-insert
:ni "M-:" #'eval-expression
;; Text size controls
:ni "C-=" #'text-scale-increase
:ni "C--" #'text-scale-decrease
:ni "C-M-=" #'doom/increase-font-size
:ni "C-M--" #'doom/decrease-font-size)
(setq vterm-min-window-width 1)
(setq ansi-color-bold-is-bright t)
(setq vterm-set-bold-hightbright t)
(setq confirm-kill-processes nil)
;; (setq kill-buffer-query-functions nil)
#+end_src #+end_src
Making a function to open vterm in a new frame. Vterm needs to be attached to some buffer,
so this function generates a new one, and then a hook is needed to clear the buffer upon exit
from the terminal.
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; (defun vterm-frame (&optional new-t) (company-posframe-mode 1)
;; "Open a new terminal frame. #+end_src
;; If `new-t` is t, a new frame is created.
;; If `new-t` is nil, use the selected frame."
;; (interactive)
;; (let ((frame (if new-t (make-frame) (selected-frame))))
;; (with-selected-frame frame
;; (let ((default-directory "~"))
;; (let ((buffer (generate-new-buffer "*vterm*")))
;; (switch-to-buffer buffer)
;; (vterm-mode))))))
(defun vterm-frame (&optional new-t)
"Open a new terminal frame.
If `new-t` is t, a new frame is created.
If `new-t` is nil, use the selected frame.
If a buffer with vterm-mode is not visible, switch to it."
(interactive)
(let* ((buffers-with-vterm (cl-remove-if-not (lambda (buf)
(with-current-buffer buf
(and (derived-mode-p 'vterm-mode)
(not (get-buffer-window buf t)))))
(buffer-list)))
(buffer (car buffers-with-vterm)))
(if buffer
(switch-to-buffer buffer)
(let ((frame (if new-t (make-frame) (selected-frame))))
(with-selected-frame frame
(let ((default-directory "~"))
(let ((buffer (generate-new-buffer "*vterm*")))
(switch-to-buffer buffer)
(vterm-mode))))))))
(add-hook 'vterm-exit-functions #'(lambda (buffer str) * Fonts
(kill-buffer buffer) ** Default
(if (one-window-p) #+begin_src emacs-lisp
(delete-frame (selected-frame) t) (add-to-list 'default-frame-alist '(font . "Symbols Nerd Font Mono 15"))
(delete-window (selected-window))))) (add-to-list 'default-frame-alist '(font . "FiraCode 15"))
(set-face-font 'variable-pitch "Inter Display 15")
(set-fontset-font "fontset-default" 'han "Source Han Sans")
#+end_src
(defun vterm-send-escape () ** Mixed Pitch Mode
(vterm-send-key "<escape>") #+begin_src emacs-lisp :tangle packages.el
(package! mixed-pitch)
#+end_src
* Coloring
There are four ways to start emacs with the combinations of GUI/TUI and standalone/daemon.
Unfortunately, each of these four methods requires a slightly different way to set window transparency.
** Themes
#+begin_src emacs-lisp :tangle packages.el
(package! gruber-darker-theme)
(package! no-clown-fiesta-theme)
#+end_src
#+begin_src emacs-lisp
(add-to-list 'custom-theme-load-path "~/.config/doom/themes/")
(load-theme 'some-clown-fiesta t)
;; GUI transparency
(set-frame-parameter nil 'alpha-background 80)
(add-to-list 'default-frame-alist '(alpha-background . 80))
;; Variable sized org headers
(custom-set-faces!
'(org-document-title :height 1.5)
'(org-document-info :height 1.3)
'(org-level-1 :height 1.5)
'(org-level-2 :height 1.4)
'(org-level-3 :height 1.3)
'(org-level-4 :height 1.2)
'(org-level-5 :height 1.1)
'(org-level-6 :height 1.0)
'(org-level-7 :height 1.0)
'(org-level-8 :height 1.0)
'(default :background "black"))
(defun ag/terminal-faces (frame)
(set-face-attribute 'hl-line frame :background "unspecified-bg")
(set-face-attribute 'org-block frame :background "unspecified-bg")
(set-face-attribute 'default frame :background "unspecified-bg"))
;; (set-face-background 'hl-line "unspecified-bg" frame))
;; (custom-set-faces!
;; ))
;; '(default :background "unspecified-bg" frame)
;; '(org-block :background "unspecified-bg" frame)
;; '(hl-line :background "unspecified-bg" frame)))
(defun window-transparency ()
(if (display-graphic-p (selected-frame))
(progn ;; $ emacs
;; Transparency for graphical session
) )
(progn ;; $ emacs -nw
;; Transparency for terminal session
(ag/terminal-faces (selected-frame)))))
(unless (daemonp)
(add-hook 'window-setup-hook 'window-transparency))
(defun ag/make-client-frame (frame)
;; Called at the creation of each emacsclient frame
(if (display-graphic-p frame)
(progn ;; $ emacsclient -c
;; Transparency for specific graphical frame
)
(progn ;; $ emacsclient -nw
;; Transparency for specific terminal frame
(ag/terminal-faces frame))))
(add-hook 'after-make-frame-functions 'ag/make-client-frame)
#+end_src
Keybinds in order to increase/decrease the transparency of emacs windows in GUI mode. I try to keep these
bindings in sync with the terminal that I use, as to make the experiences of GUI and TUI emacs relatively similar.
#+begin_src emacs-lisp
(defun ag/adjust-alpha-background (delta)
"Increase or decrease the alpha-background by DELTA, not exceeding 1 or going below 0."
(interactive "p")
;; let* macro instead of let, since new-alpha relies on alpha
(let* ((current-alpha (or (frame-parameter (selected-frame) 'alpha-background) 0))
(new-alpha (+ current-alpha delta)))
(when (and (<= new-alpha 100) (>= new-alpha 0))
(set-frame-parameter (selected-frame) 'alpha-background new-alpha))))
(global-set-key (kbd "M-a") (lambda () (interactive) (ag/adjust-alpha-background 5)))
(global-set-key (kbd "M-s") (lambda () (interactive) (ag/adjust-alpha-background -5)))
#+end_src #+end_src
* Languages * Languages
@ -303,24 +441,108 @@ From: https://tecosaur.github.io/emacs-config/config.html
(eval `(lsp-org-babel-enable ,lang))) (eval `(lsp-org-babel-enable ,lang)))
#+end_src #+end_src
** Python # ** Typst
# Automatically compile typst documents upon save
# #+begin_src emacs-lisp
# (use-package! typst-mode)
# (add-hook 'after-save-hook (lambda ()
# (when (and (buffer-file-name)
# (string= (file-name-extension (buffer-file-name)) "typ"))
# (let ((filename (shell-quote-argument (buffer-file-name))))
# (shell-command (format "typst compile %s" filename))))))
# #+end_src
** Org
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package lsp-pyright (add-hook 'org-mode-hook 'mixed-pitch-mode)
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(tree-sitter-hl-mode)
(lsp)))) ; or lsp-deferred
#+end_src #+end_src
** Typst
Automatically compile typst documents upon save
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package! typst-mode) (setq org-src-fontify-natively t)
(add-hook 'after-save-hook (lambda () #+end_src
(when (and (buffer-file-name) *** Org Modern
(string= (file-name-extension (buffer-file-name)) "typ")) #+begin_src emacs-lisp :tangle packages.el
(let ((filename (shell-quote-argument (buffer-file-name)))) (package! org-modern)
(shell-command (format "typst compile %s" filename)))))) #+end_src
*** Special symbols/characters
#+begin_src emacs-lisp
(after! org
(setq
org-superstar-headline-bullets-list '("⁖" "◉" "•" "◦" "•" "◦" "•" "◦" "•" "◦")
org-superstar-itembullet-alist '((?+ . ?➤) (?- . ?✦)))) ; changes +/- symbols in item lists
(defun ag/prettify-me ()
(setq prettify-symbols-alist
'(("TODO" . "")
("WAIT" . "")
("NOPE" . "")
("DONE" . "")
("[ ]" . "")
("[X]" . "")
("[-]" . "")
("#+begin_src" . "")
("#+BEGIN_SRC" . "")
("#+end_src" . "")
("#+END_SRC" . "")
(":properties:" . "")
(":PROPERTIES:" . "")
("#+property:" . "")
("#+PROPERTY:" . "")
(":end:" . "―")
(":END:" . "―")
("#+options:" . "")
("#+OPTIONS:" . "")
("#+startup:" . "")
("#+STARTUP:" . "")
("#+title: " . "")
("#+TITLE: " . "")
("#+TOC:" . "󰠶")
("#+toc:" . "󰠶")
("#+results:" . "")
("#+RESULTS:" . "")
("#+name:" . "")
("#+NAME:" . "")
("#+roam_tags:" . "")
("#+ROAM_TAGS:" . "")
("#+filetags:" . "")
("#+FILETAGS:" . "")
("#+html_head:" . "")
("#+HTML_HEAD:" . "")
("#+subtitle:" . "")
("#+SUBTITLE:" . "")
("#+author:" . "󰙏")
("#+AUTHOR:" . "󰙏")
(":effort:" . "")
(":EFFORT:" . "")
("scheduled:" . "")
("SCHEDULED:" . "")
("deadline:" . "")
("DEADLINE:" . ""))))
(add-hook 'org-mode-hook 'ag/prettify-me)
;; Can probably remove duplicates with
;; (mapcan (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
#+end_src
*** Agenda
#+begin_src emacs-lisp
(setq org-agenda-files
'("~/.local/share/org-agenda"))
(map! :leader :desc "Open org calendar" "o c" #'cfw:open-org-calendar)
(add-hook 'calendar-after-frame-setup-hook 'cfw:refresh-calendar-buffer)
#+end_src
*** SVG Tags
#+begin_src emacs-lisp :tangle packages.el
(package! svg-tag-mode)
#+end_src
#+begin_src emacs-lisp
(use-package! svg-tag-mode)
(setq svg-tag-tags
'((":TODO:" . ((lambda (tag) (svg-tag-make "TODO"))))
("[X]" . ((lambda (tag) (svg-tag-make "X"))))))
#+end_src #+end_src
** Shell ** Shell
@ -352,257 +574,14 @@ Automatically compile typst documents upon save
company-ispell)))) company-ispell))))
#+end_src #+end_src
* Tweaks/Fixes * Miscellaneous
** Scale line number size with buffer text ** Anki
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle packages.el
(add-hook 'text-scale-mode-hook (lambda() (face-remap--remap-face 'line-number))) (package! anki-connect)
(add-hook 'text-scale-mode-hook (lambda() (face-remap--remap-face 'line-number-current-line))) (package! anki-editor)
#+end_src
** Block cursor not showing up in terminal mode
Corresponding package in package.el
#+begin_src emacs-lisp
(use-package! evil-terminal-cursor-changer
:hook (tty-setup . evil-terminal-cursor-changer-activate))
#+end_src
*** TODO : Figure out how to tangle package.el inside config.org
** Disable "Really Quit Emacs" Prompt
#+begin_src emacs-lisp
(setq confirm-kill-emacs nil)
#+end_src #+end_src
** Relative Line Numbers ** Face Explorer
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle packages.el
(setq display-line-numbers-type 'relative) (package! face-explorer)
#+end_src
** Doom Dashboard
#+begin_src emacs-lisp
(defun doom-dashboard-widget-shortmenu ()
(insert "\n")
(dolist (section +doom-dashboard-menu-sections)
(cl-destructuring-bind (label &key icon action when face key) section
(when (and (fboundp action)
(or (null when)
(eval when t)))
(insert
(+doom-dashboard--center
(- +doom-dashboard--width 1)
(let ((icon (if (stringp icon) icon (eval icon t))))
(format (format "%s%%s%%-10s" (if icon "%3s\t" "%3s"))
(or icon "")
(with-temp-buffer
(insert-text-button
label
'action
`(lambda (_)
(call-interactively (or (command-remapping #',action)
#',action)))
'face (or face 'doom-dashboard-menu-title)
'follow-link t
'help-echo
(format "%s (%s)" label
(propertize (symbol-name action) 'face 'doom-dashboard-menu-desc)))
(format "%-37s" (buffer-string)))
;; Lookup command keys dynamically
(propertize
(or key
(when-let*
((keymaps
(delq
nil (list (when (bound-and-true-p evil-local-mode)
(evil-get-auxiliary-keymap +doom-dashboard-mode-map 'normal))
+doom-dashboard-mode-map)))
(key
(or (when keymaps
(where-is-internal action keymaps t))
(where-is-internal action nil t))))
(with-temp-buffer
(save-excursion (insert (key-description key)))
(while (re-search-forward "<\\([^>]+\\)>" nil t)
(let ((str (match-string 1)))
(replace-match
(upcase (if (< (length str) 3)
str
(substring str 0 3))))))
(buffer-string)))
"")
'face 'doom-dashboard-menu-desc))))
;; (if (display-graphic-p)
;; "\n\n"
;; "\n"))))))
"\n"))))) ;; Overwrote above lines so remove the extra newline in graphical mode from the doom dashboard
(remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-footer) ;; No github at bottom
#+end_src
** Vertico
#+begin_src emacs-lisp
(vertico-posframe-mode 1)
(setq vertico-multiform-commands
'((consult-line
posframe
(vertico-posframe-poshandler . posframe-poshandler-frame-top-center)
(vertico-posframe-border-width . 10)
;; NOTE: This is useful when emacs is used in both in X and
;; terminal, for posframe do not work well in terminal, so
;; vertico-buffer-mode will be used as fallback at the
;; moment.
(vertico-posframe-fallback-mode . vertico-buffer-mode))
(t posframe)))
(vertico-multiform-mode 1)
#+end_src
** Scrolloff
#+begin_src emacs-lisp
(setq ag/scroll-margin 8) ;; Custom var
(setq scroll-margin ag/scroll-margin)
;; Exceptions for modes that need 0 scroll margin
(add-hook 'eat-mode-hook (lambda () (setq-local scroll-margin 0)))
(add-hook 'eat-exit-hook (lambda () (setq-local scroll-margin ag/scroll-margin)))
(add-hook '+doom-dashboard-mode-hook (lambda () (setq-local scroll-margin 0)))
#+end_src
** Scratch Buffer Mode
Scratch buffer is, by default, in interactive lisp mode. Default to just plaintext.
#+begin_src emacs-lisp
(setq initial-major-mode 'text-mode)
#+end_src
** Unsetting bindings that step on mine
#+begin_src emacs-lisp
(unbind-key "M-a" c-mode-base-map)
;; The C package adds a keybind to (ccls-navigate "D"), which not
;; only steps on my binding, but is not even a provided function.
(map! :after ccls
:map (c-mode-map c++-mode-map)
:n "C-h" nil
:n "C-j" nil
:n "C-k" nil
:n "C-l" nil)
#+end_src
* Evil
** Leave insert/visual modes with C-C
#+begin_src emacs-lisp
(define-key evil-insert-state-map (kbd "C-c") 'evil-normal-state)
(define-key evil-visual-state-map (kbd "C-c") 'evil-normal-state)
#+end_src
** Clearing highlight with C-L
Mimics the "redraw" signal sent to terminals for vim.
#+begin_src emacs-lisp
(define-key evil-normal-state-map (kbd "C-l") 'evil-ex-nohighlight)
#+end_src
** Resize font in insert mode
These are the same keybinds that are able to work outside of insert mode.
#+begin_src emacs-lisp
(define-key evil-insert-state-map (kbd "C-M-=") 'doom/increase-font-size)
(define-key evil-insert-state-map (kbd "C-M--") 'doom/decrease-font-size)
(define-key evil-insert-state-map (kbd "C-=") 'text-scale-increase)
(define-key evil-insert-state-map (kbd "C--") 'text-scale-decrease)
#+end_src
** Swap g[k/j] and k/j
#+begin_src emacs-lisp
(define-key evil-motion-state-map (kbd "gj") 'evil-next-line)
(define-key evil-motion-state-map (kbd "gk") 'evil-previous-line)
(define-key evil-motion-state-map (kbd "j") 'evil-next-visual-line)
(define-key evil-motion-state-map (kbd "k") 'evil-previous-visual-line)
#+end_src
* Fonts
#+begin_src emacs-lisp
(add-to-list 'default-frame-alist '(font . "Symbols Nerd Font Mono 15"))
(add-to-list 'default-frame-alist '(font . "FiraCode 15"))
(set-fontset-font "fontset-default" 'han "Source Han Sans")
#+end_src
* Elisp Evaluation
#+begin_src emacs-lisp
(map! :leader
(:prefix ("e". "evaluate")
:desc "Evaluate elisp in buffer" "b" #'eval-buffer
:desc "Evaluate defun" "d" #'eval-defun
:desc "Evaluate elisp expression" "e" #'eval-expression
:desc "Evaluate last sexpression" "l" #'eval-last-sexp
:desc "Evaluate elisp in region" "r" #'eval-region))
#+end_src
* Coloring
There are four ways to start emacs with the combinations of GUI/TUI and standalone/daemon.
Unfortunately, each of these four methods requires a slightly different way to set window transparency.
#+begin_src emacs-lisp
(add-to-list 'custom-theme-load-path "~/.config/doom/themes/")
(load-theme 'some-clown-fiesta t)
;; GUI transparency
(set-frame-parameter nil 'alpha-background 80)
(add-to-list 'default-frame-alist '(alpha-background . 80))
;; Variable sized org headers
(custom-set-faces!
'(org-document-title :height 1.5)
'(org-document-info :height 1.3)
'(org-level-1 :height 1.5)
'(org-level-2 :height 1.4)
'(org-level-3 :height 1.3)
'(org-level-4 :height 1.2)
'(org-level-5 :height 1.1)
'(org-level-6 :height 1.0)
'(org-level-7 :height 1.0)
'(org-level-8 :height 1.0)
'(default :background "black"))
(defun ag/terminal-faces (frame)
(set-face-attribute 'hl-line frame :background "unspecified-bg")
(set-face-attribute 'org-block frame :background "unspecified-bg")
(set-face-attribute 'default frame :background "unspecified-bg"))
;; (set-face-background 'hl-line "unspecified-bg" frame))
;; (custom-set-faces!
;; ))
;; '(default :background "unspecified-bg" frame)
;; '(org-block :background "unspecified-bg" frame)
;; '(hl-line :background "unspecified-bg" frame)))
(defun window-transparency ()
(if (display-graphic-p (selected-frame))
(progn ;; $ emacs
;; Transparency for graphical session
)
(progn ;; $ emacs -nw
;; Transparency for terminal session
(ag/terminal-faces (selected-frame)))))
(unless (daemonp)
(add-hook 'window-setup-hook 'window-transparency))
(defun ag/make-client-frame (frame)
;; Called at the creation of each emacsclient frame
(if (display-graphic-p frame)
(progn ;; $ emacsclient -c
;; Transparency for specific graphical frame
)
(progn ;; $ emacsclient -nw
;; Transparency for specific terminal frame
(ag/terminal-faces frame))))
(add-hook 'after-make-frame-functions 'ag/make-client-frame)
#+end_src
Keybinds in order to increase/decrease the transparency of emacs windows in GUI mode. I try to keep these
bindings in sync with the terminal that I use, as to make the experiences of GUI and TUI emacs relatively similar.
#+begin_src emacs-lisp
(defun ag/adjust-alpha-background (delta)
"Increase or decrease the alpha-background by DELTA, not exceeding 1 or going below 0."
(interactive "p")
;; let* macro instead of let, since new-alpha relies on alpha
(let* ((current-alpha (or (frame-parameter (selected-frame) 'alpha-background) 0))
(new-alpha (+ current-alpha delta)))
(when (and (<= new-alpha 100) (>= new-alpha 0))
(set-frame-parameter (selected-frame) 'alpha-background new-alpha))))
(global-set-key (kbd "M-a") (lambda () (interactive) (ag/adjust-alpha-background 5)))
(global-set-key (kbd "M-s") (lambda () (interactive) (ag/adjust-alpha-background -5)))
#+end_src #+end_src

View file

@ -1,75 +0,0 @@
;; -*- no-byte-compile: t; -*-
;;; $DOOMDIR/packages.el
;; To install a package with Doom you must declare them here and run 'doom sync'
;; on the command line, then restart Emacs for the changes to take effect -- or
;; use 'M-x doom/reload'.
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;(package! some-package)
;; To install a package directly from a remote git repo, you must specify a
;; `:recipe'. You'll find documentation on what `:recipe' accepts here:
;; https://github.com/radian-software/straight.el#the-recipe-format
;(package! another-package
; :recipe (:host github :repo "username/repo"))
;; If the package you are trying to install does not contain a PACKAGENAME.el
;; file, or is located in a subdirectory of the repo, you'll need to specify
;; `:files' in the `:recipe':
;(package! this-package
; :recipe (:host github :repo "username/repo"
; :files ("some-file.el" "src/lisp/*.el")))
;; If you'd like to disable a package included with Doom, you can do so here
;; with the `:disable' property:
;(package! builtin-package :disable t)
;; You can override the recipe of a built in package without having to specify
;; all the properties for `:recipe'. These will inherit the rest of its recipe
;; from Doom or MELPA/ELPA/Emacsmirror:
;(package! builtin-package :recipe (:nonrecursive t))
;(package! builtin-package-2 :recipe (:repo "myfork/package"))
;; Specify a `:branch' to install a package from a particular branch or tag.
;; This is required for some packages whose default branch isn't 'master' (which
;; our package manager can't deal with; see radian-software/straight.el#279)
;(package! builtin-package :recipe (:branch "develop"))
;; Use `:pin' to specify a particular commit to install.
;(package! builtin-package :pin "1a2b3c4d5e")
;; Doom's packages are pinned to a specific commit and updated from release to
;; release. The `unpin!' macro allows you to unpin single packages...
;(unpin! pinned-package)
;; ...or multiple packages
;(unpin! pinned-package another-pinned-package)
;; ...Or *all* packages (NOT RECOMMENDED; will likely break things)
;(unpin! t)
; Fixes lack of block cursor in terminal emacs
(package! evil-terminal-cursor-changer)
(package! face-explorer)
(package! emacs-eat
:recipe (:host codeberg :repo "akib/emacs-eat"
:files ("*.el" ("term" "term/*.el") "*.texi"
"*.ti" ("terminfo/e" "terminfo/e/*")
("terminfo/65" "terminfo/65/*")
("integration" "integration/*")
(:exclude ".dir-locals.el" "*-tests.el"))))
(package! lsp-pyright)
(package! vertico-posframe)
(package! gruber-darker-theme)
(package! no-clown-fiesta-theme)
(package! mutt-mode)
(package! anki-connect)
(package! anki-editor)
(package! typst-mode)
; Making org mode look good
(package! writeroom-mode)
(package! org-modern)
(package! svg-tag-mode)
(package! mixed-pitch)