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.

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