config.el (13148B)
1 ;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- 2 3 ;; Place your private configuration here! Remember, you do not need to run 'doom 4 ;; sync' after modifying this file! 5 6 7 ;; Some functionality uses this to identify you, e.g. GPG configuration, email 8 ;; clients, file templates and snippets. 9 (setq user-full-name "Anders Hedman" 10 user-mail-address "anders.hedman01@gmail.com") 11 12 ;;Doom exposes five (optional) variables for controlling fonts in Doom. Here 13 ;; are the three important ones: 14 ;; 15 ;; + `doom-font' 16 ;; + `doom-variable-pitch-font' 17 ;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for 18 ;; presentations or streaming. 19 ;; 20 ;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd 21 ;; font string. You generally only need these two: 22 ;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light) 23 ;; doom-variable-pitch-font (font-spec :family "sans" :size 13)) 24 25 ;; There are two ways to load a theme. Both assume the theme is installed and 26 ;; available. You can either set `doom-theme' or manually load a theme with the 27 ;; `load-theme' function. This is the default: 28 (setq doom-theme 'doom-one) 29 30 ;; If you use `org' and don't want your org files in the default location below, 31 ;; change `org-directory'. It must be set before org loads! 32 (setq org-directory "~/NC/org/") 33 34 ;; This determines the style of line numbers in effect. If set to `nil', line 35 ;; numbers are disabled. For relative line numbers, set this to `relative'. 36 (setq display-line-numbers-type t) 37 38 39 ;; Here are some additional functions/macros that could help you configure Doom: 40 ;; 41 ;; - `load!' for loading external *.el files relative to this one 42 ;; - `use-package!' for configuring packages 43 ;; - `after!' for running code after a package has loaded 44 ;; - `add-load-path!' for adding directories to the `load-path', relative to 45 ;; this file. Emacs searches the `load-path' when you load packages with 46 ;; `require' or `use-package'. 47 ;; - `map!' for binding new keys 48 ;; 49 ;; To get information about any of these functions/macros, move the cursor over 50 ;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k'). 51 ;; This will open documentation for it, including demos of how they are used. 52 ;; 53 ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how 54 ;; they are implemented. 55 56 (add-to-list 'initial-frame-alist '(fullscreen . maximized)) 57 58 (defun random-choice (items) 59 (nth (random (length items)) items)) 60 61 ;;(random-choice '("a" "b" "c")) 62 63 (setq doom-themes-treemacs-theme 'Default) ; AKA doom-color 64 ;;(setq doom-themes-treemacs-theme 'doom-color) 65 ;;(setq doom-themes-treemacs-theme 'doom-atom) 66 67 (setq doom-modeline-major-mode-icon t) 68 (setq confirm-kill-emacs nil) 69 ;;(setq fancy-splash-image "~/.doom.d/splash/doom-emacs-dash.png") 70 ;;(setq fancy-splash-image "~/.doom.d/splash/doom-emacs-color.png") 71 ;;(setq fancy-splash-image "~/.doom.d/splash/doom-emacs.png") 72 73 (setq fancy-splash-image 74 (random-choice 75 '("~/.doom.d/splash/doom-emacs-dash.png" 76 "~/.doom.d/splash/doom-emacs-color.png" 77 "~/.doom.d/splash/emacs-og.png" 78 "~/.doom.d/splash/emacs-pen.png" 79 ;;"~/.doom.d/splash/gnu-bw.png" 80 ;;"~/.doom.d/splash/gnu.png" 81 ;;"~/.doom.d/splash/stallman.png" 82 "~/.doom.d/splash/doom-emacs.png"))) 83 84 (map! :leader :prefix "o" 85 "l" #'elfeed) 86 87 ;; Markdown nesting troublesome with nativecomp 88 ;; Exclude markdown from nativecomp instead of setting nested nil 89 ;; From lisp/doom-packages.el 90 (when (featurep 'native-compile) 91 (after! comp 92 ;; HACK Disable native-compilation for some troublesome packages 93 (mapc (doom-partial #'add-to-list 'native-comp-deferred-compilation-deny-list) 94 (list 95 "/markdown-.*\\.el\\'" 96 )))) 97 (setq markdown-nested-imenu-heading-index t) 98 99 (setq-default fill-column 70) 100 (use-package! visual-fill-column 101 :config 102 (setq-default visual-fill-column-width 77) 103 (setq-default visual-fill-column-center-text nil) 104 ) 105 106 (use-package! org 107 ;; Set above, before org load (setq org-directory "~/NC/org/") 108 :config 109 (setq org-ellipsis " ▾") 110 (setq org-agenda-files "~/NC/org/agenda.org") 111 (setq org-log-done 'time) 112 (setq org-log-into-drawer t) 113 (custom-set-faces! 114 '(org-document-title :height 1.3) 115 '(org-level-1 :inherit outline-1 :height 1.4) 116 '(org-level-2 :inherit outline-2 :height 1.15) 117 '(org-level-3 :inherit outline-3 :height 1.12) 118 '(org-level-4 :inherit outline-4 :height 1.09) 119 '(org-level-5 :inherit outline-5 :height 1.06) 120 '(org-level-6 :inherit outline-6 :height 1.03) 121 ) 122 (setq org-refile-targets 123 '(("archive.org" :maxlevel . 1) 124 ("todo.org" :maxlevel . 1) 125 ("docs.org" :maxlevel . 1) 126 )) 127 (setq org-capture-templates 128 '(("t" "todo" entry 129 (file "inbox.org") 130 "* TODO %? \n%i\n%a" :prepend t) 131 ("n" "notes" entry 132 (file+headline +org-capture-notes-file "Inbox") 133 "* %u %?\n%i\n%a" :prepend t) 134 ("j" "journal" entry 135 (file+olp+datetree +org-capture-journal-file) 136 "* %U %?\n%i\n%a" :prepend t))) 137 (setq org-agenda-custom-commands 138 '(("A" "Agenda and all TODOs" 139 ((agenda "") 140 (alltodo ""))) 141 ("u" "Unscheduled Todos" 142 ((alltodo "" 143 ((org-agenda-overriding-header "Unscheduled") 144 (org-agenda-skip-function '(org-agenda-skip-entry-if 145 'scheduled 146 'deadline 147 'regexp ":ongoing:") 148 ))))) 149 ) 150 ) 151 (advice-add 'org-refile :after 'org-save-all-org-buffers) 152 ) 153 154 ;; org-present config 155 (after! org 156 (defun my/org-present-start () 157 (text-scale-set 5) 158 (setq display-line-numbers nil) 159 (setq visual-fill-column-width 50) 160 (setq visual-fill-column-center-text t) 161 (visual-fill-column-mode 1) 162 (visual-line-mode 1)) 163 164 (defun my/org-present-end () 165 (setq display-line-numbers t) 166 (setq visual-fill-column-width 77) 167 (setq visual-fill-column-center-text nil) 168 (visual-fill-column-mode 0) 169 (visual-line-mode 0)) 170 171 (defun my/org-present-prepare-slide (buffer-name heading) 172 (org-overview) 173 (org-fold-show-entry) 174 (org-fold-show-children)) 175 176 (add-hook 'org-present-mode-hook 'my/org-present-start) 177 (add-hook 'org-present-mode-quit-hook 'my/org-present-end) 178 (add-hook 'org-present-after-navigate-functions 'my/org-present-prepare-slide) 179 ) 180 181 (use-package! treemacs 182 :config 183 (treemacs-indent-guide-mode 1) 184 (treemacs-follow-mode t)) 185 186 (after! treemacs 187 (treemacs-modify-theme "Default" 188 :icon-directory "~/.local/share/icons" 189 :config 190 (progn 191 (treemacs-create-icon :file "ansible.png" :fallback " " :extensions ("inventory" "ansible.cfg" ".ansible-lint" "ansible-navigator.yml")) 192 (treemacs-create-icon :file "gitlab-logo-250.png" :fallback " " :extensions (".gitlab-ci.yml"))))) 193 194 (after! mu4e 195 (setq mu4e-update-interval (* 60 60)) 196 197 (set-email-account! "Gmail" 198 '((mu4e-sent-folder . "/Gmail/[Gmail]/Sent Mail") 199 (mu4e-drafts-folder . "/Gmail/[Gmail]/Drafts") 200 (mu4e-trash-folder . "/Gmail/[Gmail]/Trash") 201 (mu4e-refile-folder . "/Gmail/[Gmail]/All Mail") 202 ;;(smtpmail-smtp-user . "anders.hedman01@gmail.com") 203 (mu4e-compose-signature . "---\nAnders Hedman")) 204 t) 205 206 (set-email-account! "andersuno.nu" 207 '((mu4e-sent-folder . "/andersuno.nu/Sent") 208 (mu4e-drafts-folder . "/andersuno.nu/Drafts") 209 (mu4e-trash-folder . "/andersuno.nu/Trash") 210 (mu4e-refile-folder . "/andersuno.nu/Archive") 211 (user-mail-address . "anders@andersuno.nu") 212 (smtpmail-smtp-user . "anders@andersuno.nu") 213 (mu4e-compose-signature . "---\nAnders Hedman")) 214 t) 215 216 (setq mu4e-maildir-shortcuts 217 '((:maildir "/Gmail/INBOX" :key ?i) 218 (:maildir "/Gmail/[Gmail]/Sent Mail" :key ?s) 219 (:maildir "/Gmail/[Gmail]/Drafts" :key ?d) 220 (:maildir "/Gmail/[Gmail]/Trash" :key ?t) 221 (:maildir "/Gmail/[Gmail]/All Mail" :key ?a) 222 (:maildir "/andersuno.nu/INBOX" :key ?I) 223 (:maildir "/andersuno.nu/Sent" :key ?S) 224 (:maildir "/andersuno.nu/Drafts" :key ?D) 225 (:maildir "/andersuno.nu/Trash" :key ?T) 226 (:maildir "/andersuno.nu/Archive" :key ?A))) 227 228 (setq mu4e-bookmarks 229 '((:name "Unread messages" 230 :query "flag:unread AND NOT flag:trashed AND maildir:/Gmail/INBOX OR maildir:/andersuno.nu/INBOX AND flag:unread" 231 :key ?u) 232 (:name "Today's messages" 233 :query "date:today..now AND maildir:/Gmail/INBOX" 234 :key ?t) 235 (:name "Last 7 days" 236 :query "date:7d..now AND maildir:/Gmail/INBOX" 237 :hide-unread t 238 :key ?w) 239 (:name "Messages with images" 240 :query "mime:image/*" 241 :key ?p))) 242 243 (setq smtpmail-smtp-server "mail.andersuno.nu" 244 smtpmail-stream-type 'ssl 245 smtpmail-smtp-service 30465) 246 ) 247 248 ;; Ansible-mode customizations 249 (def-project-mode! +ansible-yaml-mode 250 :modes '(yaml-mode) 251 :add-hooks '(ansible-mode ansible-auto-decrypt-encrypt ansible-doc-mode) 252 :files (or "roles/" "tasks/main.yml" "local.yml" "inventory" "ansible.cfg")) 253 254 (defun ansible-navigator-run () 255 "Utilize terminal-here-launch to run BUFFER with ansible-navigator" 256 (interactive) 257 (terminal-here-launch (list "ansible-navigator" "run" (buffer-file-name)))) 258 259 (defun ansible-navigator-run-check () 260 "Utilize terminal-here-launch to run BUFFER with ansible-navigator with option 261 -C/--check" 262 (interactive) 263 (terminal-here-launch (list "ansible-navigator" "run" (buffer-file-name) "-C"))) 264 265 (defun ansible-navigator-run-tags (tags) 266 "Utilize terminal-here-launch to run BUFFER with ansible-navigator with option 267 -t/--tags TAGS" 268 (interactive "sTags: ") 269 (terminal-here-launch (list "ansible-navigator" "run" (buffer-file-name) (format "-t %s" tags)))) 270 271 (defun ansible-navigator-run-check-tags (tags) 272 "Utilize terminal-here-launch to run BUFFER with ansible-navigator with option 273 -C/--check and -t/--tags TAGS" 274 (interactive "sTags: ") 275 (terminal-here-launch (list "ansible-navigator" "run" (buffer-file-name) "-C" (format "-t %s" tags)))) 276 277 (use-package! ansible 278 :config 279 (map! :map ansible-key-map 280 :localleader 281 :desc "Navigator run" "r" #'ansible-navigator-run 282 :desc "Navigator check" "c" #'ansible-navigator-run-check 283 :desc "Navigator run tags" "T" #'ansible-navigator-run-tags 284 :desc "Navigator check tags" "t" #'ansible-navigator-run-check-tags 285 )) 286 287 (use-package! kubernetes 288 :defer t 289 :commands (kubernetes-overview) 290 :config 291 (setq kubernetes-poll-frequency 3600 292 kubernetes-redraw-frequency 3600)) 293 294 (use-package! kubernetes-evil 295 :after (kubernetes-overview)) 296 297 (setq imenu-list-focus-after-activation t) 298 (map! :leader 299 :prefix "o" 300 :desc "Toggle imenu-list" "i" #'imenu-list-smart-toggle) 301 302 (defun my/lsp-vars () 303 ;; (interactive) 304 (setq lsp-terraform-ls-enable-show-reference t) 305 (setq lsp-semantic-tokens-enable t) 306 (setq lsp-headerline-breadcrumb-enable t) 307 (setq lsp-yaml-custom-tags ["!reference sequence" "!Ref sequence"]) 308 (setq lsp-semantic-tokens-honor-refresh-requests t)) 309 ;; (setq lsp-terraform-ls-prefill-required-fields t)) 310 (add-hook 'lsp-mode-hook 'my/lsp-vars) 311 312 (map! :map terraform-mode-map 313 :localleader 314 :desc "format buffer" "f" #'terraform-format-buffer) 315 316 (use-package! substitute 317 :config 318 (setq substitute-fixed-letter-case nil) 319 (add-hook 'substitute-post-replace-functions #'substitute-report-operation) 320 (map! :prefix "M-#" 321 :desc "Substitute below point" "s" #'substitute-target-below-point 322 :desc "Substitute above point" "r" #'substitute-target-above-point 323 :desc "Substitute across defun" "d" #'substitute-target-in-defun 324 :desc "Substitute across buffer" "b" #'substitute-target-in-buffer)) 325 326 (use-package! forge 327 :after magit 328 :config 329 (add-to-list 'forge-alist '("git.mh.citytest.se" "git.mh.citytest.se/api/v4" "git.mh.citytest.se" forge-gitlab-repository))) 330 331 (use-package! elpher 332 :config 333 (setq elpher-default-url-type "gemini")) 334 335 ;; (use-package! gitlab-ci-mode 336 ;; :config 337 ;; (add-to-list 'auto-mode-alist '("ci.yml\\'" . gitlab-ci-mode)) 338 ;; ) 339 340 (defun set-exec-path-from-shell-PATH () 341 "Set up Emacs' `exec-path' and PATH environment variable to match 342 that used by the user's shell. 343 344 This is particularly useful under Mac OS X and macOS, where GUI 345 apps are not started from a shell." 346 (interactive) 347 (let ((path-from-shell (replace-regexp-in-string 348 "[ \t\n]*$" "" (shell-command-to-string 349 "$SHELL --login -c 'echo $PATH'" 350 )))) 351 (setenv "PATH" path-from-shell) 352 (setq exec-path (split-string path-from-shell path-separator)))) 353 354 ;; (set-exec-path-from-shell-PATH)