Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

481 lines
18 KiB

  1. ;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
  2. ;; __ _______ _____ _____
  3. ;; \ \ / / ____| ____|_ _|
  4. ;; \ V /| _| | _| | |
  5. ;; | | | |___| |___ | |
  6. ;; |_| |_____|_____| |_|
  7. ;; Yeet's Doom Emacs configuration
  8. ;; Global Configuration
  9. (setq user-full-name "Yigit Colakoglu"
  10. user-mail-address "yigit@yigitcolakoglu.com")
  11. (setq org-directory "~/Documents/org/")
  12. (setq org-journal-dir "~/Documents/org/journal/")
  13. (setq display-line-numbers-type 'relative)
  14. (setq twittering-allow-insecure-server-cert t)
  15. (setq org-hugo-base-dir "~/Projects/fr1nge.xyz")
  16. (setq org-hugo-default-section-directory "~/Projects/fr1nge.xyz")
  17. (setq +ivy-buffer-preview t)
  18. (global-auto-revert-mode t)
  19. (global-subword-mode 1) ; Iterate through CamelCase words
  20. (setq-default
  21. delete-by-moving-to-trash t ; Delete files to trash
  22. window-combination-resize t ; take new window space from all other windows (not just current)
  23. x-stretch-cursor t) ; Stretch cursor to the glyph width
  24. (setq undo-limit 80000000 ; Raise undo-limit to 80Mb
  25. evil-want-fine-undo t ; By default while in insert all changes are one big blob. Be more granular
  26. auto-save-default t ; Nobody likes to loose work, I certainly don't
  27. truncate-string-ellipsis "") ; Unicode ellispis are nicer than "...", and also save /precious/ space
  28. ;; Experimental, delete if you don't like it
  29. (setq evil-vsplit-window-right t
  30. evil-split-window-below t)
  31. (require 'gas-mode)
  32. (add-to-list 'auto-mode-alist '("\\.S\\'" . gas-mode))
  33. (require 'bison-mode)
  34. (after! bison-mode-hook
  35. (setq imenu-create-index-function
  36. (lambda ()
  37. (let ((end))
  38. (beginning-of-buffer)
  39. (re-search-forward "^%%")
  40. (forward-line 1)
  41. (setq end (save-excursion (re-search-forward "^%%") (point)))
  42. (loop while (re-search-forward "^\\([a-z].*?\\)\\s-*\n?\\s-*:" end t)
  43. collect (cons (match-string 1) (point)))))))
  44. (defadvice! prompt-for-buffer (&rest _)
  45. :after '(evil-window-split evil-window-vsplit)
  46. (+ivy/switch-buffer))
  47. (use-package! ox-hugo
  48. :after ox
  49. )
  50. (use-package! elfeed-org
  51. :after elfeed
  52. :config
  53. (elfeed-org)
  54. (setq rmh-elfeed-org-files (list "~/.doom.d/elfeed.org"))
  55. )
  56. (use-package! deft
  57. :hook deft-mode-hook :init (setq deft-directory org-directory) (setq deft-recursive t)
  58. )
  59. (use-package! hl-todo
  60. :hook (prog-mode . hl-todo-mode)
  61. :config
  62. (setq hl-todo-keyword-faces
  63. `(
  64. ("PROJ" . ,(face-foreground 'error))
  65. ("SOMEDAY" . ,(face-foreground 'warning))
  66. ("TODO" . ,(face-foreground 'warning))
  67. ("PROG" . ,(face-foreground 'error))
  68. ("NEXT" . ,(face-foreground 'error))
  69. ("WAIT" . ,(face-foreground 'warning))
  70. ("CANCEL" . ,(face-foreground 'error))
  71. ("DELEGATED" . ,(face-foreground 'error))
  72. ("IDEA" . ,(face-foreground 'warning))
  73. ("GOAL" . ,(face-foreground 'warning))
  74. ("DUD" . ,(face-foreground 'error))
  75. ("RD" . ,(face-foreground 'warning))
  76. ("RDING" . ,(face-foreground 'warning))
  77. ("RDNOTE" . ,(face-foreground 'warning))
  78. ("TMPDROP" . ,(face-foreground 'warning))
  79. ("DROP" . ,(face-foreground 'error))
  80. ("FNSHED" . ,(face-foreground 'success))
  81. ("DONE" . ,(face-foreground 'success)))))
  82. (use-package! engrave-faces-latex
  83. :after ox-latex)
  84. (use-package! org-ol-tree
  85. :commands org-ol-tree)
  86. (use-package! org-chef
  87. :commands (org-chef-insert-recipe org-chef-get-recipe-from-url))
  88. (use-package! org-pretty-table
  89. :commands (org-pretty-table-mode global-org-pretty-table-mode))
  90. (use-package! aas :commands aas-mode)
  91. (use-package! laas
  92. :hook (LaTeX-mode . laas-mode)
  93. :config
  94. (defun laas-tex-fold-maybe ()
  95. (unless (equal "/" aas-transient-snippet-key)
  96. (+latex-fold-last-macro-a)))
  97. (add-hook 'aas-post-snippet-expand-hook #'laas-tex-fold-maybe))
  98. (use-package! calfw-org
  99. :after calfw)
  100. (use-package! org-download
  101. :defer
  102. :init
  103. ;; Org download
  104. (setq-default org-download-image-dir "~/Pictures/org/")
  105. (setq-default org-download-method 'directory)
  106. (setq-default org-download-screenshot-method "scrot")
  107. :config
  108. (org-download-enable)
  109. )
  110. (add-hook! 'dired-mode-hook 'org-download-enable)
  111. (use-package! org-agenda
  112. :defer
  113. :init
  114. (setq org-agenda-files (list
  115. (concat org-directory "projects.org")
  116. (concat org-directory "monthly_habits.org")
  117. (concat org-directory "quarterly_habits.org")
  118. (concat org-directory "personal.org")
  119. (concat org-directory "taxes.org")
  120. (concat org-directory "birthdays_and_important_days.org")
  121. (concat org-directory "reading_list.org")
  122. (concat org-directory "school.org")
  123. (concat org-directory "daily_habits.org")
  124. (concat org-directory "weekly_habits.org")
  125. (concat org-directory "reflections/2021_refl.org")
  126. (concat org-directory "someday.org")
  127. (concat org-directory "projects/2021/")
  128. org-journal-dir))
  129. :config
  130. (setq org-habit-show-habits-only-for-today t)
  131. ;; Org Agenda Files
  132. ;; org agenda
  133. (setq org-agenda-time-grid
  134. (quote
  135. ((daily today remove-match)
  136. (700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300)
  137. "......" "----------------")))
  138. )
  139. (use-package! org-super-agenda
  140. :after org-agenda
  141. :init
  142. ;; for some reason org-agenda evil bindings were being weird with j and k
  143. (map! :map org-agenda-keymap "j" #'org-agenda-next-line)
  144. (map! :map org-agenda-mode-map "j" #'org-agenda-next-line)
  145. (map! :map org-super-agenda-header-map "j" #'org-agenda-next-line)
  146. (map! :map org-agenda-keymap "k" #'org-agenda-previous-line)
  147. (map! :map org-agenda-mode-map "k" #'org-agenda-previous-line)
  148. (map! :map org-super-agenda-header-map "k" #'org-agenda-previous-line)
  149. (map! :map org-super-agenda-header-map "k" #'org-agenda-previous-line)
  150. (map! :map org-super-agenda-header-map "k" #'org-agenda-previous-line)
  151. (setq org-agenda-custom-commands '(
  152. ("r" "Main View"
  153. ((agenda "" ((org-agenda-span 'day)
  154. (org-agenda-start-day "+0d")
  155. (org-agenda-overriding-header "")
  156. (org-super-agenda-groups
  157. '((:name "Today"
  158. :time-grid t
  159. :date today
  160. :order 1
  161. :scheduled today
  162. :todo "TODAY")))))
  163. (alltodo "" ((org-agenda-overriding-header "")
  164. (org-super-agenda-groups
  165. '(
  166. (:discard (:habit))
  167. (:todo "PROJ")
  168. (:todo "PROG")
  169. (:todo "NEXT")
  170. (:todo "WAIT")
  171. (:todo "RD")
  172. (:todo "RDING")
  173. (:todo "RDNOTE")
  174. (:name "Important" :priority "A")
  175. (:todo "TODO")
  176. (:todo "GOAL")
  177. (:discard (:todo "IDEA"))
  178. (:discard (:todo "RD"))
  179. (:discard (:todo "TMPDROP"))
  180. (:discard (:todo "SOMEDAY"))
  181. ))))))
  182. ("w" "Someday and Idea"
  183. ((alltodo "" ((org-agenda-overriding-header "")
  184. (org-super-agenda-groups
  185. '(
  186. (:todo "IDEA")
  187. (:todo "SOMEDAY")
  188. (:discard (:todo "PROJ"))
  189. (:discard (:todo "PROG"))
  190. (:discard (:todo "NEXT"))
  191. (:discard (:todo "WAIT"))
  192. (:discard (:todo "RDNOTE"))
  193. (:discard (:todo "RD"))
  194. (:discard (:todo "RDING"))
  195. (:discard (:todo "TODO"))
  196. (:discard (:todo "GOAL"))
  197. )
  198. )))))))
  199. :config
  200. (org-super-agenda-mode))
  201. ;; Org Roam
  202. (use-package! org-roam
  203. :commands (org-roam-insert org-roam-find-file org-roam)
  204. :init
  205. (setq org-roam-directory (concat org-directory "roam"))
  206. (setq org-roam-buffer-width 0.2)
  207. (map! :leader
  208. :prefix "n"
  209. :desc "Org-Roam-Insert" "i" #'org-roam-insert
  210. :desc "Org-Roam-Find" "/" #'org-roam-find-file
  211. :desc "Org-Roam-Buffer" "r" #'org-roam)
  212. )
  213. ;; Attempt to remove lag
  214. (setq key-chord-two-keys-delay 0.7)
  215. (after! org (load! "org-conf.el"))
  216. ;; Better window management
  217. (map! :map evil-window-map
  218. "SPC" #'rotate-layout
  219. ;; Navigation
  220. "<left>" #'evil-window-left
  221. "<down>" #'evil-window-down
  222. "<up>" #'evil-window-up
  223. "<right>" #'evil-window-right
  224. ;; Swapping windows
  225. "C-<left>" #'+evil/window-move-left
  226. "C-<down>" #'+evil/window-move-down
  227. "C-<up>" #'+evil/window-move-up
  228. "C-<right>" #'+evil/window-move-right)
  229. (after! company
  230. (setq company-idle-delay 0.2
  231. company-minimum-prefix-length 2))
  232. (after! evil-escape (evil-escape-mode -1))
  233. (after! evil (setq evil-ex-substitute-global t)) ; I like my s/../.. to by global by default
  234. (setq emojify-emoji-set "twemoji-v2")
  235. (setq-default history-length 1000)
  236. (setq-default prescient-history-length 1000)
  237. (set-company-backend!
  238. '(text-mode
  239. markdown-mode
  240. gfm-mode)
  241. '(:seperate
  242. company-ispell
  243. company-files
  244. company-yasnippet))
  245. (setq
  246. default-directory "~"
  247. web-mode-markup-indent-offset 4
  248. ispell-dictionary "en-custom"
  249. web-mode-code-indent-offset 4
  250. web-mode-css-indent-offset 4
  251. js-indent-level 4
  252. json-reformat:indent-width 4
  253. prettier-js-args '("--single-quote")
  254. projectile-project-search-path '("~/Projects/")
  255. dired-dwim-target t
  256. nand-hdl-directory "~/Projects/nand2tetris"
  257. css-indent-offset 2)
  258. (org-babel-do-load-languages
  259. 'org-babel-load-languages
  260. '((dot . t))) ;
  261. (setq auth-sources
  262. '((:source "~/.config/emacs/.authinfo.gpg")))
  263. (defun insert-current-date () (interactive)
  264. (insert (shell-command-to-string "echo -n $(date +%Y-%m-%d)")))
  265. (defun org-insert-clipboard-image () (interactive)
  266. (setq name (read-from-minibuffer "Enter image description: "))
  267. (setq file (concat "./static/" (subst-char-in-string ? ?_ (nth 0 (org-get-outline-path t))) "/" (format-time-string "%Y-%m-%dT%T") "_" (subst-char-in-string ? ?_ name) ".png"))
  268. (setq return (shell-command-to-string (concat "saveclipimg " file)))
  269. (insert (concat "[[file:" return"][" name "]]"))
  270. (org-display-inline-images))
  271. ;; We expect the encoding to be LF UTF-8, so only show the modeline when this is not the case
  272. (defun doom-modeline-conditional-buffer-encoding ()
  273. (setq-local doom-modeline-buffer-encoding
  274. (unless (and (memq (plist-get (coding-system-plist buffer-file-coding-system) :category)
  275. '(coding-category-undecided coding-category-utf-8))
  276. (not (memq (coding-system-eol-type buffer-file-coding-system) '(1 2))))
  277. t)))
  278. (add-hook 'after-change-major-mode-hook #'doom-modeline-conditional-buffer-encoding)
  279. (map! :ne "M-/" #'comment-or-uncomment-region)
  280. (map! :ne "SPC / r" #'deadgrep)
  281. (map! :ne "SPC n b" #'org-brain-visualize)
  282. (map! :ne "SPC i d" #'insert-current-date)
  283. ;; zoom in/out like we do everywhere else.
  284. (global-set-key (kbd "C-=") 'text-scale-increase)
  285. (global-set-key (kbd "C--") 'text-scale-decrease)
  286. (global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)
  287. (global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
  288. (setq +magit-hub-features t)
  289. (setq calc-angle-mode 'rad ; radians are rad
  290. calc-symbolic-mode t) ; keeps expressions like \sqrt{2} irrational for as long as possible
  291. (use-package! calctex
  292. :commands calctex-mode
  293. :init
  294. (add-hook 'calc-mode-hook #'calctex-mode)
  295. :config
  296. (setq calctex-additional-latex-packages "
  297. \\usepackage[usenames]{xcolor}
  298. \\usepackage{soul}
  299. \\usepackage{adjustbox}
  300. \\usepackage{amsmath}
  301. \\usepackage{amssymb}
  302. \\usepackage{siunitx}
  303. \\usepackage{cancel}
  304. \\usepackage{mathtools}
  305. \\usepackage{mathalpha}
  306. \\usepackage{xparse}
  307. \\usepackage{arevmath}"
  308. calctex-additional-latex-macros
  309. (concat calctex-additional-latex-macros
  310. "\n\\let\\evalto\\Rightarrow"))
  311. (defadvice! no-messaging-a (orig-fn &rest args)
  312. :around #'calctex-default-dispatching-render-process
  313. (let ((inhibit-message t) message-log-max)
  314. (apply orig-fn args)))
  315. ;; Fix hardcoded dvichop path (whyyyyyyy)
  316. (let ((vendor-folder (concat (file-truename doom-local-dir)
  317. "straight/"
  318. (format "build-%s" emacs-version)
  319. "/calctex/vendor/")))
  320. (setq calctex-dvichop-sty (concat vendor-folder "texd/dvichop")
  321. calctex-dvichop-bin (concat vendor-folder "texd/dvichop")))
  322. (unless (file-exists-p calctex-dvichop-bin)
  323. (message "CalcTeX: Building dvichop binary")
  324. (let ((default-directory (file-name-directory calctex-dvichop-bin)))
  325. (call-process "make" nil nil nil))))
  326. (defun greedily-do-daemon-setup ()
  327. (require 'org)
  328. (when (require 'elfeed nil t)
  329. (run-at-time nil (* 8 60 60) #'elfeed-update)))
  330. ;; Open new clients in the dashboard
  331. (when (daemonp)
  332. (add-hook 'emacs-startup-hook #'greedily-do-daemon-setup)
  333. (add-hook! 'server-after-make-frame-hook (switch-to-buffer +doom-dashboard-name)))
  334. (set-popup-rule! "^\\*Org Agenda" :side 'bottom :size 0.90 :select t :ttl nil)
  335. (set-popup-rule! "^\\*org-brain" :side 'right :size 1.00 :select t :ttl nil)
  336. (sp-local-pair
  337. '(org-mode)
  338. "<<" ">>"
  339. :actions '(insert))
  340. (setq +zen-text-scale 0.8)
  341. (use-package! lexic
  342. :commands lexic-search lexic-list-dictionary
  343. :config
  344. (map! :map lexic-mode-map
  345. :n "q" #'lexic-return-from-lexic
  346. :nv "RET" #'lexic-search-word-at-point
  347. :n "a" #'outline-show-all
  348. :n "h" (cmd! (outline-hide-sublevels 3))
  349. :n "o" #'lexic-toggle-entry
  350. :n "n" #'lexic-next-entry
  351. :n "N" (cmd! (lexic-next-entry t))
  352. :n "p" #'lexic-previous-entry
  353. :n "P" (cmd! (lexic-previous-entry t))
  354. :n "E" (cmd! (lexic-return-from-lexic) ; expand
  355. (switch-to-buffer (lexic-get-buffer)))
  356. :n "M" (cmd! (lexic-return-from-lexic) ; minimise
  357. (lexic-goto-lexic))
  358. :n "C-p" #'lexic-search-history-backwards
  359. :n "C-n" #'lexic-search-history-forwards
  360. :n "/" (cmd! (call-interactively #'lexic-search))))
  361. (defadvice! +lookup/dictionary-definition-lexic (identifier &optional arg)
  362. :override #'+lookup/dictionary-definition
  363. (interactive
  364. (list (or (doom-thing-at-point-or-region 'word)
  365. (read-string "Look up in dictionary: "))
  366. current-prefix-arg))
  367. (lexic-search identifier nil nil t))
  368. ;; Hooks
  369. (add-hook 'nand-hdl-mode-hook 'yas-minor-mode)
  370. (defun after-org-mode-load ()
  371. (interactive)
  372. (setq olivetti-body-width 0.8)
  373. (olivetti-mode)
  374. )
  375. (add-hook! 'org-mode-hook 'after-org-mode-load)
  376. ;; Auto-Insert
  377. (autoload 'yas-expand-snippet "yasnippet")
  378. (defun my-autoinsert-yas-expand()
  379. "Replace text in yasnippet template."
  380. (yas-expand-snippet (buffer-string) (point-min) (point-max)))
  381. (setq-default auto-insert-directory "~/.config/doom/templates")
  382. (auto-insert-mode 1) ;;; Adds hook to find-files-hook
  383. (setq-default auto-insert-query nil) ;;; If you don't want to be prompted before insertion
  384. (define-auto-insert "\\.el$" ["template.el" my-autoinsert-yas-expand])
  385. (define-auto-insert "\\.c$" ["template.c" my-autoinsert-yas-expand])
  386. (define-auto-insert "\\.cpp$" ["template.cpp" my-autoinsert-yas-expand])
  387. (define-auto-insert "\\.h$" ["template.h" my-autoinsert-yas-expand])
  388. (define-auto-insert "\\.cc$" ["template.cpp" my-autoinsert-yas-expand])
  389. (define-auto-insert "\\.tex$" ["template.tex" my-autoinsert-yas-expand])
  390. (define-auto-insert "\\.org$" ["template.org" my-autoinsert-yas-expand])
  391. (define-auto-insert "\\.py$" ["template.py" my-autoinsert-yas-expand])
  392. (define-auto-insert "\\.java$" ["template.java" my-autoinsert-yas-expand])
  393. (define-auto-insert "\\.sh$" ["template.sh" my-autoinsert-yas-expand])
  394. (define-auto-insert "\\.html$" ["template.html" my-autoinsert-yas-expand])
  395. (setq yas-snippet-dirs
  396. '("~/.config/doom/snippets"))
  397. ;; Appearance
  398. (delq! t custom-theme-load-path) ;; Don't prompt on startup
  399. (setq doom-theme 'doom-material-ocean)
  400. (setq
  401. doom-big-font (font-spec :family "CasaydiaCove Nerd Font" :size 22)
  402. doom-font (font-spec :family "CaskaydiaCove Nerd Font" :size 16)
  403. doom-variable-pitch-font (font-spec :family "Overpass" :size 16)
  404. doom-unicode-font (font-spec :family "JuliaMono")
  405. doom-serif-font (font-spec :family "IBM Plex Mono" :weight 'light))
  406. (setq +doom-dashboard-banner-file (expand-file-name "logo.png" doom-private-dir))
  407. ;; Use xclip globally
  408. (xclip-mode)