dotfiles/.config/doom/config.el

318 lines
11 KiB
EmacsLisp
Raw Normal View History

2020-10-07 19:41:29 +00:00
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "Janek"
2020-10-07 19:41:29 +00:00
user-mail-address "27jf@pm.me")
2021-03-26 18:02:37 +00:00
;;;; VISUALS
2020-10-07 19:41:29 +00:00
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones:
;;
;; + `doom-font'
;; + `doom-variable-pitch-font'
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;;
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
;; font string. You generally only need these two:
;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
;; doom-variable-pitch-font (font-spec :family "sans" :size 13))
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-one
2021-03-20 10:12:10 +00:00
doom-font (font-spec :family "monospace" :size 24 :weight 'semi-light)
doom-variable-pitch-font (font-spec :family "sans" :size 24))
(setq display-line-numbers-type 'relative)
2021-04-02 19:01:26 +00:00
(setq evil-respect-visual-line-mode nil)
(add-hook 'visual-line-mode-hook (lambda () (setq line-move-visual nil)))
2021-03-26 18:02:37 +00:00
;;;; BINDINGS
(defun dragon ()
; Share file in current buffer via dragon
(interactive)
(shell-command (concat "dragon-drag-and-drop -x " (buffer-file-name)))
)
;; rebing C-u - https://emacs.stackexchange.com/a/58320
(global-set-key (kbd "C-#") 'universal-argument)
(define-key universal-argument-map (kbd "C-#") 'universal-argument-more)
2021-03-26 18:02:37 +00:00
(global-set-key (kbd "C-*") 'universal-argument)
(define-key universal-argument-map (kbd "C-*") 'universal-argument-more)
(map! :leader "u" 'evil-prev-buffer
:leader "i" 'evil-next-buffer
:leader "bq" 'doom/save-and-kill-buffer
:leader "d" 'dragon
;; Buffer-local font resizing
:n "M-C-=" 'text-scale-increase
:n "M-C--" 'text-scale-decrease
;; Frame-local font resizing
:n "C-=" 'doom/increase-font-size
:n "C--" 'doom/decrease-font-size
)
2021-03-26 18:02:37 +00:00
;;;; GLOBAL SETUP
;; Undo
(setq evil-want-fine-undo t)
(setq amalgamating-undo-limit 5)
(setq confirm-kill-emacs nil)
(setq initial-major-mode 'org-mode)
2020-10-15 08:12:25 +00:00
2020-12-07 20:55:59 +00:00
(whitespace-mode 0)
(setq eww-search-prefix "https://safe.duckduckgo.com/html/?q=")
2021-03-20 10:12:10 +00:00
(setq lazy-highlight-cleanup nil)
2020-10-07 19:41:29 +00:00
;; Backups & auto-saves
2021-02-24 11:19:09 +00:00
(setq auto-save-default t
auto-save-interval 40)
(setq make-backup-files t
backup-directory-alist (list (cons "." (concat doom-cache-dir "backup/")))
delete-old-versions t
version-control t
vc-make-backup-files t
kept-new-versions 5
kept-old-versions 3
)
2020-10-07 19:41:29 +00:00
;; Data dirs
2020-10-07 19:41:29 +00:00
(defvar user-data-dir "~/data" "Location of the main user data")
2020-10-07 19:41:29 +00:00
(load! "./local.el" nil t)
2021-03-26 18:02:37 +00:00
(setq org-directory (expand-file-name "2-standards/notes" user-data-dir))
(setq default-directory org-directory)
(setq initial-buffer-choice (expand-file-name "journal/log.org" org-directory))
(setq org-roam-directory (concat (file-name-as-directory (getenv "XDG_DATA_HOME")) "org-roam"))
;;; UTF-8 encoding - https://zhangda.wordpress.com/2016/02/15/configurations-for-beautifying-emacs-org-mode/
;; disable CJK coding/encoding (Chinese/Japanese/Korean characters)
(setq utf-translate-cjk-mode nil)
(set-language-environment 'utf-8)
(setq locale-coding-system 'utf-8)
;; set the default encoding system
(prefer-coding-system 'utf-8)
(setq default-file-name-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;; backwards compatibility as default-buffer-file-coding-system
;; is deprecated in 23.2.
(if (boundp buffer-file-coding-system)
(setq buffer-file-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8))
;; Treat clipboard input as UTF-8 string first; compound text next, etc.
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
;;;; ORG
(after! org
(setq org-agenda-files
(apply 'append
(mapcar
(lambda (directory) (directory-files-recursively (expand-file-name directory user-data-dir) org-agenda-file-regexp))
'("1-projects" "2-standards" "3-resources")
)))
(defun org-todo-or-insert (&optional arg)
(interactive "P")
(if (org-at-heading-p) (org-todo arg) (org-insert-todo-heading arg t)))
(defun org-timestamp-up-week ()
(interactive)
2021-04-02 19:01:26 +00:00
(let ((current-prefix-arg '(7))) (call-interactively 'org-timestamp-up-day))
)
(defun org-export-repeat ()
(interactive)
(let ((current-prefix-arg '(4))) (call-interactively 'org-export-dispatch))
)
2021-03-26 18:02:37 +00:00
(map! :map org-mode-map
:localleader
"j" 'org-insert-heading
"t" 'org-todo-or-insert
"E" 'org-export-repeat
2021-04-02 19:01:26 +00:00
"d=" 'org-timestamp-up-week
"rt" 'org-todo-region
"ra" 'org-change-tag-in-region
)
2021-03-26 18:02:37 +00:00
(define-key org-mode-map (kbd "C-c .") 'org-time-stamp-inactive)
(define-key org-mode-map (kbd "M-C-+") 'org-timestamp-up)
(define-key org-mode-map (kbd "M-C--") 'org-timestamp-down)
2021-03-26 18:02:37 +00:00
;; Toggle source blocks with C-c t
(defvar org-blocks-hidden nil)
(defun org-toggle-blocks ()
"Toggle all source code blocks."
(interactive)
(if org-blocks-hidden
(org-show-block-all)
(org-hide-block-all))
(setq-local org-blocks-hidden (not org-blocks-hidden)))
(define-key org-mode-map (kbd "C-c t") 'org-toggle-blocks)
;; https://christiantietze.de/posts/2019/06/org-fold-heading/
(defun ct/org-foldup ()
"Hide the entire subtree from root headline at point."
(interactive)
(while (ignore-errors (outline-up-heading 1)))
(org-flag-subtree t))
(defun ct/org-shifttab (&optional arg)
(interactive "P")
(if (or (null (org-current-level)) ; point is before 1st heading, or
(and (= 1 (org-current-level)) ; at level-1 heading, or
(org-at-heading-p))
(org-at-table-p)) ; in a table (to preserve cell movement)
; perform org-shifttab at root level elements and inside tables
(org-shifttab arg)
; try to fold up elsewhere
(ct/org-foldup)))
(define-key org-mode-map (kbd "S-<tab>") 'ct/org-shifttab)
;; https://emacs.stackexchange.com/questions/38529/make-multiple-lines-todos-at-once-in-org-mode
(defun org-todo-region ()
(interactive)
(let ((scope (if mark-active 'region 'tree))
(state (org-fast-todo-selection))
(org-enforce-todo-dependencies nil))
(org-map-entries (lambda () (org-todo state)) nil scope)))
)
2020-10-07 19:41:29 +00:00
2021-03-26 18:02:37 +00:00
;; Behavior
(set-file-template! 'org-mode :ignore t)
(setq org-read-date-prefer-future nil)
2021-03-26 18:02:37 +00:00
;; Visuals
2020-12-07 20:55:59 +00:00
(setq org-image-actual-width nil)
2021-03-26 18:02:37 +00:00
(setq org-ellipsis "")
2021-02-24 11:19:09 +00:00
;; Exporting - https://orgmode.org/manual/Export-Settings.html
2021-03-15 15:51:50 +00:00
(setq org-latex-pdf-process '("latexmk -outdir=/tmp/latexmk -f -pdf %F; mv %f /tmp/latexmk; mv /tmp/latexmk/%b.pdf %o")) ; https://emacs.stackexchange.com/a/48351
2021-03-20 10:12:10 +00:00
(setq org-latex-packages-alist '(("margin=2cm" "geometry") ("avoid-all" "widows-and-orphans")))
2020-12-07 20:55:59 +00:00
(setq org-export-with-tags nil)
2021-03-20 10:12:10 +00:00
(setq org-export-with-tasks 'done)
(setq org-export-with-todo-keywords nil)
2020-10-07 19:41:29 +00:00
2021-02-24 11:19:09 +00:00
;; Org startup - https://orgmode.org/manual/In_002dbuffer-Settings.html
2021-02-22 18:11:32 +00:00
(setq org-startup-folded 'show2levels)
2021-01-30 20:54:06 +00:00
(setq org-startup-with-inline-images t)
2021-03-01 11:00:43 +00:00
(setq org-display-remote-inline-images 'cache)
2021-01-30 20:54:06 +00:00
2021-03-26 18:02:37 +00:00
;; Fix xdg-open & pdfs - https://depp.brause.cc/dotemacs/#orgd97f08c
2021-02-24 11:19:09 +00:00
(setq org-file-apps '((remote . emacs)
2021-03-15 15:51:50 +00:00
("\\.pdf\\'" . default)
2021-02-24 11:19:09 +00:00
(auto-mode . emacs)
(directory . emacs)
(system . "setsid -w xdg-open %s")
(t . system)))
2021-02-25 11:24:50 +00:00
;; https://discord.com/channels/406534637242810369/406554085794381833/814175445004189706
;(after! org
; (add-to-list 'org-file-apps '(system . "setsid -w xdg-open %s"))
2021-02-24 11:19:09 +00:00
2021-03-26 18:02:37 +00:00
;; Automated logging for todos - https://stackoverflow.com/questions/12262220/add-created-date-property-to-todos-in-org-mode/52815573#52815573
(setq org-log-done 'time)
(setq org-log-into-drawer t)
(setq org-treat-insert-todo-heading-as-state-change t)
;;;; PACKAGES
2021-02-22 18:11:32 +00:00
;; https://emacs.stackexchange.com/questions/16744/magit-help-popup-enabled-by-default
(defadvice magit-status (after my-magit-status-dispatch-popup)
(call-interactively 'magit-dispatch))
2021-02-22 18:11:32 +00:00
(ad-activate 'magit-status)
(use-package! evil-replace-with-register ; gr
:init
(setq evil-replace-with-register-key (kbd "gr"))
(evil-replace-with-register-install)
:config
(defun eval-paragraph ()
(interactive)
(er/mark-paragraph)
(call-interactively '+eval:region)
)
(map! :n "gR" 'eval-paragraph
:v "gR" '+eval/region)
)
2021-02-25 11:24:50 +00:00
(use-package! evil-args ; https://github.com/wcsmith/evil-args
:config
;; bind evil-args text objects
(define-key evil-inner-text-objects-map "a" 'evil-inner-arg)
(define-key evil-outer-text-objects-map "a" 'evil-outer-arg)
;; bind evil-forward/backward-args
(define-key evil-normal-state-map "L" 'evil-forward-arg)
(define-key evil-normal-state-map "H" 'evil-backward-arg)
(define-key evil-motion-state-map "L" 'evil-forward-arg)
(define-key evil-motion-state-map "H" 'evil-backward-arg)
;; bind evil-jump-out-args
(define-key evil-normal-state-map "K" 'evil-jump-out-args)
)
2021-04-02 19:01:26 +00:00
; (use-package evil-better-visual-line
; :ensure t
; :config
; (evil-better-visual-line-on))
2021-02-25 11:24:50 +00:00
(use-package! direnv ; nix-shell stuffs
:config
(setq direnv-always-show-summary nil)
(direnv-mode)
)
(use-package! plantuml-mode ; Diagrams
:config
2021-03-26 18:02:37 +00:00
(setq plantuml-executable-path "nostderr"
plantuml-executable-args '("plantuml" "-headless")
plantuml-default-exec-mode 'executable
plantuml-jar-path "/usr/share/java/plantuml/plantuml.jar"
org-plantuml-jar-path plantuml-jar-path
plantuml-java-args '("-Djava.awt.headless=true" "-jar")
)
(after! org
(add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
2021-02-24 11:19:09 +00:00
(org-babel-do-load-languages
'org-babel-load-languages
'(other Babel languages (plantuml . t))
)
)
)
(use-package! adoc-mode ; Asciidoc, a md alternative
:config
(add-to-list 'auto-mode-alist (cons "\\.adoc\\'" 'adoc-mode))
)
2021-03-26 18:02:37 +00:00
2020-10-07 19:41:29 +00:00
;; Here are some additional functions/macros that could help you configure Doom:
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.