I showed you my source code, pls respond
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.

450 lines
14 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. (defun dotfiles/tangle (dir)
  2. "Recursively tangle the Org files within a directory."
  3. (interactive)
  4. (let ((org-files (directory-files-recursively dir "org")))
  5. (dolist (f org-files)
  6. (org-babel-tangle-file f))))
  7. (defvar dotfiles/home user-emacs-directory)
  8. (defvar dotfiles/cache "~/.cache/emacs")
  9. (setq user-emacs-directory dotfiles/cache)
  10. (setq create-lockfiles nil
  11. make-backup-files nil)
  12. (setq straight-repository-branch "develop"
  13. straight-use-package-by-default t)
  14. (defvar bootstrap-version)
  15. (let ((bootstrap-file
  16. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  17. (bootstrap-version 5))
  18. (unless (file-exists-p bootstrap-file)
  19. (with-current-buffer
  20. (url-retrieve-synchronously
  21. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  22. 'silent 'inhibit-cookies)
  23. (goto-char (point-max))
  24. (eval-print-last-sexp)))
  25. (load bootstrap-file nil 'nomessage))
  26. (straight-use-package 'use-package)
  27. (use-package no-littering)
  28. (setq inhibit-startup-message t)
  29. (global-prettify-symbols-mode)
  30. (scroll-bar-mode -1)
  31. (menu-bar-mode -1)
  32. (tool-bar-mode -1)
  33. (tooltip-mode -1)
  34. (use-package org
  35. :hook
  36. (org-mode . (lambda ()
  37. (org-indent-mode)
  38. (visual-line-mode 1)
  39. (variable-pitch-mode 1)))
  40. :config
  41. (setq org-ellipsis ""
  42. org-log-done 'time
  43. org-log-into-drawer t
  44. org-src-preserve-indentation t)
  45. (org-babel-do-load-languages
  46. 'org-babel-load-languages
  47. '((shell . t)
  48. (python . t)
  49. (emacs-lisp . t)))
  50. (require 'org-tempo)
  51. (add-to-list 'org-structure-template-alist '("s" . "src"))
  52. (add-to-list 'org-structure-template-alist '("q" . "quote"))
  53. (add-to-list 'org-structure-template-alist '("e" . "example"))
  54. (add-to-list 'org-structure-template-alist '("sh" . "src shell"))
  55. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  56. (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")))
  57. (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
  58. (defvar dotfiles/idle 0.0)
  59. (use-package which-key
  60. :diminish which-key-mode
  61. :init (which-key-mode)
  62. :config (setq which-key-idle-delay dotfiles/idle))
  63. (defvar dotfiles/leader-key "SPC")
  64. (defvar dotfiles/leader-key-global "C-SPC")
  65. (use-package general
  66. :config
  67. (general-create-definer dotfiles/leader
  68. :states '(normal motion)
  69. :keymaps 'override
  70. :prefix dotfiles/leader-key
  71. :global-prefix dotfiles/leader-key-global))
  72. (use-package hydra)
  73. (use-package evil
  74. :init (setq evil-want-integration t
  75. evil-want-keybinding nil)
  76. :config (evil-mode 1))
  77. (use-package evil-collection
  78. :after evil
  79. :config (evil-collection-init))
  80. (use-package evil-nerd-commenter
  81. :bind ("M-;" . evilnc-comment-or-uncomment-lines))
  82. (dotfiles/leader
  83. "." '(find-file :which-key "Files")
  84. "," '(switch-to-buffer :which-key "Buffers")
  85. "c" '(kill-buffer-and-window :which-key "Close"))
  86. (dotfiles/leader
  87. "h" '(:ignore t :which-key "Help")
  88. "hp" '(describe-package :which-key "Package")
  89. "hv" '(describe-variable :which-key "Variable")
  90. "hf" '(describe-function :which-key "Function"))
  91. (dotfiles/leader
  92. "q" '(:ignore t :which-key "Quit")
  93. "qq" '(save-buffers-kill-emacs :which-key "Save")
  94. "qw" '(kill-emacs :which-key "Now")
  95. "qf" '(delete-frame :which-key "Frame"))
  96. (dotfiles/leader
  97. "w" '(:ignore t :which-key "Window")
  98. "ww" '(window-swap-states :which-key "Swap")
  99. "wc" '(delete-window :which-key "Close")
  100. "wh" '(windmove-left :which-key "Left")
  101. "wj" '(windmove-down :which-key "Down")
  102. "wk" '(windmove-up :which-key "Up")
  103. "wl" '(windmove-right :which-key "Right")
  104. "ws" '(:ignore t :which-key "Split")
  105. "wsj" '(split-window-below :which-key "Down")
  106. "wsl" '(split-window-right :which-key "Right"))
  107. (use-package magit
  108. :custom (magit-display-buffer-function
  109. #'magit-display-buffer-same-window-except-diff-v1))
  110. (use-package forge)
  111. (dotfiles/leader
  112. "g" '(magit-status :which-key "Magit"))
  113. (use-package eshell-prompt-extras
  114. :config (setq eshell-highlight-prompt nil
  115. eshell-prompt-function 'epe-theme-lambda))
  116. (dotfiles/leader
  117. "e" '(eshell :which-key "Shell"))
  118. (use-package all-the-icons)
  119. (use-package all-the-icons-dired
  120. :hook (dired-mode . all-the-icons-dired-mode))
  121. (require 'dired-x)
  122. (use-package dired-single
  123. :config
  124. (evil-collection-define-key 'normal 'dired-mode-map
  125. "h" 'dired-single-up-directory
  126. "l" 'dired-single-buffer))
  127. (dotfiles/leader
  128. "d" '(dired-jump :which-key "Dired"))
  129. (defvar dotfiles/font "Fira Code")
  130. (defvar dotfiles/font-size 96)
  131. (set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size)
  132. (set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size)
  133. (set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size)
  134. (defhydra hydra-text-scale (:timeout 4)
  135. "Scale"
  136. ("j" text-scale-increase "Increase")
  137. ("k" text-scale-decrease "Decrease")
  138. ("f" nil "Finished" :exit t))
  139. (dotfiles/leader
  140. "f" '(hydra-text-scale/body :which-key "Font"))
  141. (use-package linum-relative
  142. :init (setq linum-relative-backend
  143. 'display-line-numbers-mode)
  144. :config (linum-relative-global-mode))
  145. (use-package rainbow-delimiters
  146. :hook (prog-mode . rainbow-delimiters-mode))
  147. (use-package doom-themes
  148. :init (load-theme 'doom-moonlight t))
  149. (dotfiles/leader
  150. "t" '(load-theme t nil :which-key "Theme"))
  151. (use-package doom-modeline
  152. :init (doom-modeline-mode 1)
  153. :custom ((doom-modeline-height 16)))
  154. (defun dotfiles/run (command)
  155. (let ((command-parts (split-string command "[ ]+")))
  156. (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
  157. (defun dotfiles/set-wallpaper (path)
  158. (interactive)
  159. (when (file-exists-p path)
  160. (let ((command (concat "feh --bg-scale " path)))
  161. (start-process-shell-command "feh" nil command))))
  162. (defun dotfiles/init-hook ()
  163. (exwm-workspace-switch-create 1)
  164. (setq display-time-and-date t)
  165. (display-battery-mode 1)
  166. (display-time-mode 1))
  167. (defun dotfiles/update-display ()
  168. (dotfiles/run "autorandr --change --force")
  169. ;; (dotfiles/set-wallpaper "TODO")
  170. )
  171. (use-package exwm
  172. :config
  173. (require 'exwm-randr)
  174. (exwm-randr-enable)
  175. (add-hook 'exwm-init-hook #'dotfiles/init-hook)
  176. (add-hook 'exwm-randr-screen-change-hook #'dotfiles/update-display)
  177. (dotfiles/update-display)
  178. (setq exwm-input-prefix-keys
  179. '(?\M-x
  180. ?\C-g
  181. ?\C-\ )
  182. exwm-input-global-keys
  183. `(([?\s-r] . exwm-reset)
  184. ([?\s-&] . (lambda (command)
  185. (interactive (list (read-shell-command "λ ")))
  186. (start-process-shell-command command nil command)))
  187. ,@(mapcar (lambda (i)
  188. `(,(kbd (format "s-%d" i)) .
  189. (lambda ()
  190. (interactive)
  191. (exwm-workspace-switch-create ,i))))
  192. (number-sequence 1 9))))
  193. (exwm-enable))
  194. (use-package org-superstar
  195. :hook (org-mode . org-superstar-mode))
  196. (add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
  197. (use-package mu4e
  198. :config
  199. (setq mu4e-change-filenames-when-moving t
  200. mu4e-update-interval (* 5 60) ;; Every 5 minutes.
  201. mu4e-get-mail-command "mbsync -a"
  202. mu4e-maildir "~/.cache/mail"
  203. mu4e-compose-signature
  204. (concat "Chris Hayward\n"
  205. "https://chrishayward.xyz\n"))
  206. ;; Ensure plain text scales for all devices.
  207. (setq mu4e-compose-format-flowed t)
  208. ;; GPG signing key for outbound mail.
  209. (setq mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  210. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  211. (setq message-send-mail-function 'smtpmail-send-it)
  212. ;; Configure mail account(s).
  213. (setq mu4e-contexts
  214. (list
  215. ;; Main
  216. ;; chris@chrishayward.xyz
  217. (make-mu4e-context
  218. :name "Main"
  219. :match-func
  220. (lambda (msg)
  221. (when msg
  222. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  223. :vars
  224. '((user-full-name . "Christopher James Hayward")
  225. (user-mail-address . "chris@chrishayward.xyz")
  226. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  227. (smtpmail-smtp-service . 587)
  228. (smtpmail-stream-type . starttls))))))
  229. (dotfiles/leader
  230. "m" '(mu4e :which-key "Mail"))
  231. (use-package org-roam
  232. :hook (after-init . org-roam-mode)
  233. :custom (org-roam-directory "~/.local/source/brain"))
  234. (use-package org-roam-server
  235. :hook (org-roam-mode . org-roam-server-mode))
  236. (dotfiles/leader
  237. "r" '(:ignore t :which-key "Roam")
  238. "rf" '(org-roam-find-file :which-key "Find")
  239. "rb" '(org-roam-buffer-toggle-display :which-key "Buffer")
  240. "rc" '(org-roam-capture :which-key "Capture")
  241. "rd" '(:ignore t :which-key "Dailies")
  242. "rdd" '(org-roam-dailies-find-date :which-key "Date")
  243. "rdt" '(org-roam-dailies-find-today :which-key "Today")
  244. "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  245. "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  246. (setq org-roam-capture-templates
  247. '(("d" "Default" plain (function org-roam-capture--get-point)
  248. "%?"
  249. :file-name "${slug}"
  250. :head "#+TITLE: ${title}\n"
  251. :unnarrowed t)))
  252. (setq org-roam-dailies-capture-templates
  253. '(("d" "Default" entry (function org-roam-capture--get-point)
  254. "* %?"
  255. :file-name "daily/%<%Y-%m-%d>"
  256. :head "#+TITLE: %<%Y-%m-%d>\n")))
  257. (defvar dotfiles/bib "~/.local/source/brain/resources.bib")
  258. (defvar dotfiles/notes "~/.local/source/brain/notes/")
  259. (use-package org-noter
  260. :after org
  261. :config
  262. (setq org-noter-always-create-frame nil
  263. org-noter-notes-search-path dotfiles/notes))
  264. (use-package org-pdftools
  265. :hook (org-mode . org-pdftools-setup-link))
  266. (use-package org-noter-pdftools
  267. :after org-noter
  268. :config
  269. (with-eval-after-load 'pdf-annot
  270. (add-hook 'pdf-annot-active-handler-functions #'org-noter-pdftools-jump-to-note)))
  271. (setq bibtex-completion-notes-path dotfiles/notes
  272. bibtex-completion-bibliography dotfiles/bib
  273. bibtex-completion-pdf-field "file"
  274. bibtex-completion-notes-template-multiple-files
  275. (concat
  276. "#+TITLE: ${title}\n"
  277. "#+ROAM_KEY: cite:${=key=}\n"
  278. "#* TODO Notes\n"
  279. ":PROPERTIES:\n"
  280. ":CUSTOM_ID: ${=key}\n"
  281. ":NOTER_DOCUMENT: %(orb-process-file-field \"${=key=}\")\n"
  282. ":AUTHOR: ${author-abbrev}\n"
  283. ":JOURNAL: ${journaltitle}\n"
  284. ":DATE: ${date}\n"
  285. ":YEAR: ${year}\n"
  286. ":DOI: ${doi}\n"
  287. ":URL: ${url}\n"
  288. ":END:\n\n"))
  289. (use-package org-ref
  290. :config
  291. (setq org-ref-completion-library 'org-ref-helm-cite
  292. org-ref-get-pdf-filename-function 'org-refg-get-pdf-filename-helm-bibtex
  293. org-ref-default-bibliography dotfiles/bib
  294. org-ref-bibliography-notes dotfiles/notes
  295. org-ref-notes-directory dotfiles/notes
  296. org-ref-notes-function 'orb-edit-notes
  297. org-ref-note-title-format "* TODO %y - %t\n:PROPERTIES:\n:CUSTOM_ID: %k\n:NOTER_DOCUMENT: %F\n:ROAM_KEY: cite:%k\n:AUTHOR: %9a\n:JOURNAL: %j\n:YEAR: %y\n:VOLUME: %v\n:PAGES: %p\n:DOI: %D\n:URL: %U\n:END:\n\n"))
  298. (use-package org-roam-bibtex
  299. :after (org-roam)
  300. :hook (org-roam-mode . org-roam-bibtex-mode)
  301. :config
  302. (setq orb-preformat-keywords
  303. '("=key=" "title" "url" "file" "author-or-editor" "keywords")))
  304. (add-to-list 'org-roam-capture-templates
  305. '("n" "Notes" plain (function org-roam-capture--get-point)
  306. ""
  307. :file-name "notes/${slug}"
  308. :head "#+TITLE: ${=key=}: ${title}\n#+ROAM_KEY:${ref}\n\n* ${title} :PROPERTIES:\n:CUSTOM_ID: ${=key=}\n:URL: ${url}\n:AUTHOR: ${author-or-editor}\n:NOTER_DOCUMENT:%(orb-process-file-field \"${=key=}\")\n:NOTER_PAGE:\n:END:\n\n"))
  309. (setq org-agenda-files '("~/.local/source/brain/daily/"
  310. "~/.local/source/secrets/org/"))
  311. (dotfiles/leader
  312. "a" '(org-agenda :which-key "Agenda"))
  313. (use-package ox-hugo
  314. :after ox)
  315. (add-to-list 'org-roam-capture-templates
  316. '("b" "Blogging" plain (function org-roam-capture--get-point)
  317. "%?"
  318. :file-name "posts/${slug}"
  319. :head "#+TITLE: ${title}\n#+HUGO_BASE_DIR: ~/.local/source/website\n#+HUGO_SECTION: posts\n"))
  320. (use-package gif-screencast
  321. :custom
  322. (gif-screencast-output-directory "~/.local/source/brain/screen/"))
  323. (dotfiles/leader
  324. "s" '(:ignore t :which-key "Screencast")
  325. "ss" '(gif-screencast-start-or-stop :which-key "Start / Stop")
  326. "sp" '(gif-screencast-toggle-pause :which-key "Pause"))
  327. (use-package ox-reveal
  328. :after ox
  329. :custom (org-reveal-root "https://cdn.jsdelivr.net/reveal.js/3.9.2/"))
  330. (add-to-list 'org-roam-capture-templates
  331. '("p" "Presentation" plain (function org-roam-capture--get-point)
  332. "%?"
  333. :file-name "slides/${slug}"
  334. :head "#+TITLE: ${title}\n"))
  335. (use-package lsp-mode
  336. :custom (gc-cons-threshold 1000000000)
  337. (lsp-idle-delay 0.500))
  338. (use-package lsp-ui
  339. :custom (lsp-ui-doc-position 'at-point)
  340. (lsp-ui-doc-delay 0.500))
  341. (use-package password-store
  342. :custom (password-store-dir "~/.local/source/passwords"))
  343. (use-package dap-mode)
  344. (use-package company)
  345. (use-package company-lsp)
  346. (use-package ccls
  347. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  348. (lambda () (require 'ccls) (lsp))))
  349. (use-package python-mode
  350. :hook (python-mode . lsp)
  351. :config (require 'dap-python)
  352. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  353. (dap-python-executable "python3") ;; Same as above.
  354. (dap-python-debugger 'debugpy))
  355. (use-package rustic)
  356. (use-package go-mode
  357. :hook (go-mode . lsp))
  358. (defun dotfiles/go-hook ()
  359. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  360. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  361. (add-hook 'go-mode-hook #'dotfiles/go-hook)