dotfiles/config/xdgconfig/doom/config.el
2024-09-01 20:27:15 +02:00

364 lines
12 KiB
EmacsLisp

;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
(defun load-directory (dir)
(let ((load-it (lambda (f) (load-file (concat (file-name-as-directory dir) f)))))
(mapc load-it (directory-files dir nil "\\.el$"))))
(defun org-path-find-file ()
"Open org-path in find file"
(interactive)
(doom-project-find-file +user-org-path))
(defun org-path (filename)
"Expand filename relative to the default org-path"
(expand-file-name filename +user-org-path))
(defun my-org-inline-css-hook (exporter)
"Insert custom inline css"
(when (eq exporter 'html)
(let* ((dir (ignore-errors (file-name-directory (buffer-file-name))))
(path (concat dir "style.css"))
(fallback-style (or (null dir) (null (file-exists-p path))))
(final (if fallback-style "~/.config/doom/style.css" path))) ;; <- set your own style file path
(setq org-html-head-include-default-style t)
(setq org-html-head (concat
"<style type=\"text/css\">\n"
"<!--/*--><![CDATA[/*><!--*/\n"
(with-temp-buffer
(insert-file-contents final)
(buffer-string))
"/*]]>*/-->\n"
"</style>\n")))))
(defun my-weebery-is-always-greater ()
(let* ((banner '("EMACS "
"███▄ ▄███▓ ▒█████ ▒█████ ▓█████▄ "
"▓██▒▀█▀ ██▒▒██▒ ██▒▒██▒ ██▒▒██▀ ██▌"
"▓██ ▓██░▒██░ ██▒▒██░ ██▒░██ █▌"
"▒██ ▒██ ▒██ ██░▒██ ██░░▓█▄ ▌"
"▒██▒ ░██▒░ ████▓▒░░ ████▓▒░░▒████▓ "
"░ ▒░ ░ ░░ ▒░▒░▒░ ░ ▒░▒░▒░ ▒▒▓ ▒ "
"░ ░ ░ ░ ▒ ▒░ ░ ▒ ▒░ ░ ▒ ▒ "
"░ ░ ░ ░ ░ ▒ ░ ░ ░ ▒ ░ ░ ░ "
" ░ ░ ░ ░ ░ ░ "
""))
(longest-line (apply #'max (mapcar #'length banner))))
(put-text-property
(point)
(dolist (line banner (point))
(insert (+doom-dashboard--center
+doom-dashboard--width
(concat line (make-string (max 0 (- longest-line (length line))) 32)))
"\n"))
'face 'doom-dashboard-banner)))
(map! "C-M-+" #'doom/increase-font-size)
(map! "C-#" #'comment-line)
(map! :leader
:map doom-leader-file-map
:desc "Find org files" "f o" #'org-path-find-file)
(map! :leader
:map doom-leader-open-map
:desc "Open elfeed" "o e" #'elfeed
:desc "Open org drill" "o r" #'org-drill)
(map! :localleader
:after org
:map org-mode-map
:desc "View habit stats" "g s" #'org-habit-stats-view-habit-at-point)
;; Basic User Settings
(setq user-full-name "Jonathan Jenne"
user-mail-address "johnnie@posteo.de")
;; Set backend for finding auth credentials
(setq auth-sources
'("~/.authinfo" "~/.authinfo.gpg" "~/.netrc"))
(load-directory "~/.config/doom/lisp")
;; Default Shell
;; Useful if default system shell is not bash
(setq shell-file-name (executable-find "bash"))
(setq vterm-shell (executable-find "fish"))
;; This is where all org files are sourced from
(setq +user-org-path "~/Notes/Org")
;; Display Line numbers
(setq display-line-numbers-type t)
;; Fonts
(setq doom-font
(font-spec :family "IBM Plex Mono" :size 18 :weight 'medium))
(setq doom-variable-pitch-font
(font-spec :family "IBM Plex Serif" :size 18 :weight 'medium))
;; Dashboard
(setq +doom-dashboard-ascii-banner-fn #'my-weebery-is-always-greater)
;; (remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-shortmenu)
;; (remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-footer)
;; (remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-loaded)
(add-to-list '+doom-dashboard-menu-sections
'("Open Notmuch"
:icon (nerd-icons-faicon "nf-fa-calendar" :face 'doom-dashboard-menu-title)
:when (modulep! :email notmuch)
:face (:inherit (doom-dashboard-menu-title bold))
:action =notmuch))
(add-to-list '+doom-dashboard-menu-sections
'("Open elfeed"
:icon (nerd-icons-faicon "nf-fa-rss" :face 'doom-dashboard-menu-title)
:when (modulep! :app rss)
:face (:inherit (doom-dashboard-menu-title bold))
:action elfeed))
(use-package! notmuch
:config
(setq +notmuch-sync-backend 'offlineimap
+notmuch-home-function (lambda () (notmuch-search "tag:inbox"))
message-send-mail-function 'smtpmail-send-it
smtpmail-default-smtp-server "posteo.de"
smtpmail-stream-type 'ssl
smtpmail-smtp-service 465))
;; Org Mode
(use-package! org
:config
(setq ;; General
org-directory +user-org-path
org-log-into-drawer "LOGBOOK"
org-src-tab-acts-natively t
;; Org Export
org-export-exclude-tags '("toc")
;; Org Agenda
org-agenda-show-all-dates t
org-agenda-span 2
org-agenda-start-day "+0d"
org-agenda-tag-filter-preset '("-drill")
;; Disable timegrid since it causes errors on current org-mode 9.7
;; when org-super-agenda is also used
;; See: https://github.com/alphapapa/org-super-agenda/issues/247
;; See: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fac55324accbcab08dfebbde8295b2f1b4b9f45e
org-agenda-use-time-grid nil
org-agenda-time-grid
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
org-agenda-current-time-string
"◀── now ──────────────────────────────────────────────── \\o/"
org-agenda-block-separator ?─
;; Consider all org files part of the org-agenda
org-agenda-files (list +user-org-path)
;; org-agenda-spillover-skip-function '(org-agenda-skip-entry-if 'todo 'done)
;; Org Todo
org-todo-keywords
'((sequence "TODO(t)" "DOING(g)" "WAIT(w)" "|" "DONE(d)" "CANCEL(c)")
(sequence "THIS(T)" "EXAMPLE")
(sequence "[ ]" "[?]" "|" "[x]"))
;; Org Capture
+org-capture-notes-file (org-path "Notes.org")
+org-capture-todo-file (org-path "Todo.org")
+org-capture-journal-file (org-path "Journal.org")
+org-capture-cooking-file (org-path "Cooking.org")
+org-capture-nepali-file (org-path "Nepali.org")
org-capture-templates
'(("t" "Personal Todo" entry
(file +org-capture-todo-file)
"* TODO %^{Todo Item}" :prepend t :immediate-finish t)
("n" "Nepali")
("nw" "Nepali Word" entry
(file+headline +org-capture-nepali-file "Nepali Words")
"* %^{Nepali Word} :drill:\n%\\1\n** Answer\n%^{Translation}" :prepend t :immediate-finish t)
("s" "Shopping Item" entry
(file +org-capture-todo-file)
"* TODO %^{Shopping Item} :shopping:" :prepend t :immediate-finish t)
("j" "Daily Journal" entry
(file+olp+datetree +org-capture-journal-file)
"* %U %?\n" :prepend t)
("r" "Recipe" entry
(file+headline +org-capture-cooking-file "Unsorted")
"* NEVERMADE %?
:PROPERTIES:
:Author:
:Source:
:Sent_by:
:Yield:
:Prep_Time:
:Cook_Time:
:Total_Time:
:Cost:
:Description:
:URL:
:Added: %u
:END:
- [ ] Ingredient 1
1. First Step")))
:hook
(org-after-todo-state-change . org-habit-stats-update-properties)
:init
(add-to-list 'org-modules 'org-habit)
(add-hook 'org-export-before-processing-functions 'my-org-inline-css-hook))
(use-package! drag-stuff
:init (drag-stuff-global-mode t))
(use-package! elfeed
:init
(elfeed-protocol-enable)
:config
(evil-define-key 'normal elfeed-show-mode-map
(kbd "J") 'elfeed-goodies/split-show-next
(kbd "K") 'elfeed-goodies/split-show-prev)
(evil-define-key 'normal elfeed-search-mode-map
(kbd "J") 'elfeed-goodies/split-show-next
(kbd "K") 'elfeed-goodies/split-show-prev)
(setq elfeed-goodies/entry-pane-size 0.5
elfeed-search-filter "@2-week-ago +unread"
elfeed-protocol-feeds '(("fever+https://inhji@reader.inhji.de"
:api-url "https://reader.inhji.de/fever/"
:password "2sFTfYf7$q2Vc^tB*Pw4"))
elfeed-protocol-enabled-protocols '(fever newsblur owncloud ttrss))
(use-package! elfeed-protocol
:init
(elfeed-protocol-enable)
:config
(setq
elfeed-protcol-feeds '(("https://reader.inhji.de/fever"
:password "2sFTfYf7$q2Vc^tB*Pw4"))
elfeed-protocol-enabled-protocols '(fever newsblur owncloud ttrss)))
;; :hook
;; (add-hook elfeed-show-mode . (lambda () (buffer-face-set 'variable-pitch)))
)
(use-package! expand-region
:bind ("C-ä" . er/expand-region))
(use-package! heaven-and-hell
:ensure t
:config
(setq heaven-and-hell-theme-type 'dark ;; Omit to use light by default
heaven-and-hell-themes
'((light . doom-gruvbox-light)
(dark . doom-gruvbox)) ;; Themes can be the list: (dark . (tsdh-dark wombat))
heaven-and-hell-load-theme-no-confirm t)
:hook (after-init . heaven-and-hell-init-hook)
:bind (("<f6>" . heaven-and-hell-toggle-theme)))
(use-package! hl-todo
:config
(setq hl-todo-keyword-faces
'(("TODO" warning bold)
("EXAMPLE" font-lock-keyword-face bold)
("HACK" font-lock-constant-face bold)
("DEPRECATED" font-lock-doc-face bold)
("NOTE" success bold)
("BUG" error bold)
("THIS" font-lock-constant-face bold)))
:hook (org-mode . hl-todo-mode))
(use-package! nov
:mode ("\\.epub\\'" . nov-mode)
:config
(setq nov-text-width 70))
;; Replaced by zen mode in doom emacs
;; (use-package! olivetti
;; :init
;; (add-hook! 'nov-mode-hook 'olivetti-mode)
;; (add-hook! 'org-mode-hook
;; '(olivetti-mode
;; (lambda () (display-line-numbers-mode -1)))))
(use-package! org-auto-tangle
:defer t
:config (setq org-auto-tangle-default nil)
:hook (org-mode . org-auto-tangle-mode))
(use-package! org-caldav
:config
(setq auth-source-debug t
org-caldav-url "https://posteo.de:8443/calendars/johnnie"
org-caldav-calendar-id "default"
org-caldav-inbox (org-path "Calendar.org")
org-caldav-files nil
org-caldav-days-in-past 7
org-caldav-delete-calendar-entries 'never
org-icalendar-timezone "Europe/Berlin"))
(use-package! org-drill
:config
(setq org-drill-scope 'agenda))
(use-package! org-noter
:config
(setq org-noter-notes-search-path '("~/Notes/Org")
org-noter-always-create-frame nil
org-noter-doc-split-fraction '(0.75 . 0.75)
org-noter-default-notes-file-names '()))
(use-package! org-roam
:config
(setq org-roam-directory "~/Notes/Org/Roam"
org-roam-dailies-directory "Daily"))
(use-package! org-superstar
:hook
(org-mode . (lambda () (org-superstar-mode 1))))
(use-package! org-super-agenda
:config
(setq org-super-agenda-groups
'(;; Each group has an implicit boolean OR operator between its selectors.
(:name "Important"
;; Single arguments given alone
;;:tag "bills"
:priority "A")
(:name "Habits"
:habit t)
(:name "Appointments"
:file-path "Calendar\.org")
(:name "Inbox"
:file-path "Inbox\.org")
(:name "Shopping"
:tag "shopping")
;; Set order of multiple groups at once
(:priority<= "B"
;; Show this section after "Today" and "Important", because
;; their order is unspecified, defaulting to 0. Sections
;; are displayed lowest-number-first.
:order 1)
;; After the last group, the agenda will display items that didn't
;; match any of these groups, with the default order position of 99
))
:init
(org-super-agenda-mode t))
;; (use-package! casual
;; :init
;; (require 'casual)
;; (define-key calc-mode-map (kbd "C-o") 'casual-main-menu))