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.

476 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
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. (dotfiles/leader
  108. "t" '(:ignore t :which-key "Tweaks"))
  109. (use-package magit
  110. :custom (magit-display-buffer-function
  111. #'magit-display-buffer-same-window-except-diff-v1))
  112. (use-package forge)
  113. (dotfiles/leader
  114. "g" '(magit-status :which-key "Magit"))
  115. (use-package eshell-prompt-extras
  116. :config (setq eshell-highlight-prompt nil
  117. eshell-prompt-function 'epe-theme-lambda))
  118. (dotfiles/leader
  119. "e" '(eshell :which-key "Shell"))
  120. (use-package all-the-icons)
  121. (use-package all-the-icons-dired
  122. :hook (dired-mode . all-the-icons-dired-mode))
  123. (require 'dired-x)
  124. (use-package dired-single
  125. :config
  126. (evil-collection-define-key 'normal 'dired-mode-map
  127. "h" 'dired-single-up-directory
  128. "l" 'dired-single-buffer))
  129. (dotfiles/leader
  130. "d" '(dired-jump :which-key "Dired"))
  131. (defvar dotfiles/font "Fira Code")
  132. (defvar dotfiles/font-size 96)
  133. (set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size)
  134. (set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size)
  135. (set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size)
  136. (defhydra hydra-text-scale (:timeout 4)
  137. "Scale"
  138. ("j" text-scale-increase "Increase")
  139. ("k" text-scale-decrease "Decrease")
  140. ("f" nil "Finished" :exit t))
  141. (dotfiles/leader
  142. "tf" '(hydra-text-scale/body :which-key "Font"))
  143. (use-package linum-relative
  144. :init (setq linum-relative-backend
  145. 'display-line-numbers-mode)
  146. :config (linum-relative-global-mode))
  147. (use-package rainbow-delimiters
  148. :hook (prog-mode . rainbow-delimiters-mode))
  149. (use-package doom-themes
  150. :init (load-theme 'doom-moonlight t))
  151. (use-package doom-modeline
  152. :init (doom-modeline-mode 1)
  153. :custom ((doom-modeline-height 16)))
  154. (dotfiles/leader
  155. "tt" '(load-theme t t :which-key "Theme"))
  156. (use-package dashboard
  157. :config
  158. (setq dashboard-center-content t
  159. dashboard-startup-banner 'logo)
  160. (dashboard-setup-startup-hook))
  161. (defun dotfiles/run (command)
  162. "Run an external process."
  163. (interactive (list (read-shell-command "λ ")))
  164. (start-process-shell-command command nil command))
  165. (defun dotfiles/run-in-background (command)
  166. (let ((command-parts (split-string command "[ ]+")))
  167. (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
  168. ;; (defun dotfiles/set-wallpaper (path)
  169. ;; (interactive)
  170. ;; (when (file-exists-p path)
  171. ;; (let ((command (concat "feh --bg-scale " path)))
  172. ;; (start-process-shell-command "feh" nil command))))
  173. (dotfiles/leader
  174. "x" '(dotfiles/run :which-key "Execute"))
  175. (defun dotfiles/init-hook ()
  176. (exwm-workspace-switch-create 1)
  177. (setq display-time-and-date t)
  178. (display-battery-mode 1)
  179. (display-time-mode 1))
  180. (defun dotfiles/update-display ()
  181. (dotfiles/run-in-background "autorandr --change --force"))
  182. ;; (dotfiles/set-wallpaper "TODO"))
  183. (use-package exwm
  184. :config
  185. (require 'exwm-randr)
  186. (exwm-randr-enable)
  187. (add-hook 'exwm-init-hook #'dotfiles/init-hook)
  188. (add-hook 'exwm-randr-screen-change-hook #'dotfiles/update-display)
  189. (dotfiles/update-display)
  190. (setq exwm-input-prefix-keys
  191. '(?\M-x
  192. ?\C-g
  193. ?\C-\ )
  194. exwm-input-global-keys
  195. `(([?\s-r] . exwm-reset)
  196. ([?\s-&] . dotfiles/run)
  197. ,@(mapcar (lambda (i)
  198. `(,(kbd (format "s-%d" i)) .
  199. (lambda ()
  200. (interactive)
  201. (exwm-workspace-switch-create ,i))))
  202. (number-sequence 1 9))))
  203. (exwm-enable))
  204. (use-package org-superstar
  205. :hook (org-mode . org-superstar-mode))
  206. ;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
  207. (use-package mu4e
  208. :load-path "/usr/share/emacs/site-lisp/mu4e"
  209. :config
  210. (setq mu4e-change-filenames-when-moving t
  211. mu4e-update-interval (* 5 60) ;; Every 5 minutes.
  212. mu4e-get-mail-command "mbsync -a"
  213. mu4e-maildir "~/.cache/mail"
  214. mu4e-compose-signature
  215. (concat "Chris Hayward\n"
  216. "https://chrishayward.xyz\n"))
  217. ;; Ensure plain text scales for all devices.
  218. (setq mu4e-compose-format-flowed t)
  219. ;; GPG signing key for outbound mail.
  220. (setq mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  221. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  222. (setq message-send-mail-function 'smtpmail-send-it)
  223. ;; Configure mail account(s).
  224. (setq mu4e-contexts
  225. (list
  226. ;; Main
  227. ;; chris@chrishayward.xyz
  228. (make-mu4e-context
  229. :name "Main"
  230. :match-func
  231. (lambda (msg)
  232. (when msg
  233. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  234. :vars
  235. '((user-full-name . "Christopher James Hayward")
  236. (user-mail-address . "chris@chrishayward.xyz")
  237. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  238. (smtpmail-smtp-service . 587)
  239. (smtpmail-stream-type . starttls))))))
  240. (dotfiles/leader
  241. "m" '(mu4e :which-key "Mail"))
  242. (use-package org-roam
  243. :hook (after-init . org-roam-mode)
  244. :custom (org-roam-directory "~/.local/source/brain"))
  245. (use-package org-roam-server
  246. :hook (org-roam-mode . org-roam-server-mode))
  247. (dotfiles/leader
  248. "r" '(:ignore t :which-key "Roam")
  249. "rf" '(org-roam-find-file :which-key "Find")
  250. "rb" '(org-roam-buffer-toggle-display :which-key "Buffer")
  251. "rc" '(org-roam-capture :which-key "Capture")
  252. "rd" '(:ignore t :which-key "Dailies")
  253. "rdd" '(org-roam-dailies-find-date :which-key "Date")
  254. "rdt" '(org-roam-dailies-find-today :which-key "Today")
  255. "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  256. "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  257. (setq org-roam-capture-templates
  258. '(("d" "Default" plain (function org-roam-capture--get-point)
  259. "%?"
  260. :file-name "${slug}"
  261. :head "#+TITLE: ${title}\n"
  262. :unnarrowed t)))
  263. (setq org-roam-dailies-capture-templates
  264. '(("d" "Default" entry (function org-roam-capture--get-point)
  265. "* %?"
  266. :file-name "daily/%<%Y-%m-%d>"
  267. :head "#+TITLE: %<%Y-%m-%d>\n")))
  268. (defvar dotfiles/bib "~/.local/source/brain/resources.bib")
  269. (defvar dotfiles/notes "~/.local/source/brain/notes/")
  270. (use-package org-noter
  271. :after org
  272. :config
  273. (setq org-noter-always-create-frame nil
  274. org-noter-notes-search-path dotfiles/notes))
  275. (use-package org-pdftools
  276. :hook (org-mode . org-pdftools-setup-link))
  277. (use-package org-noter-pdftools
  278. :after org-noter
  279. :config
  280. (with-eval-after-load 'pdf-annot
  281. (add-hook 'pdf-annot-active-handler-functions #'org-noter-pdftools-jump-to-note)))
  282. (setq bibtex-completion-notes-path dotfiles/notes
  283. bibtex-completion-bibliography dotfiles/bib
  284. bibtex-completion-pdf-field "file"
  285. bibtex-completion-notes-template-multiple-files
  286. (concat
  287. "#+TITLE: ${title}\n"
  288. "#+ROAM_KEY: cite:${=key=}\n"
  289. "#* TODO Notes\n"
  290. ":PROPERTIES:\n"
  291. ":CUSTOM_ID: ${=key}\n"
  292. ":NOTER_DOCUMENT: %(orb-process-file-field \"${=key=}\")\n"
  293. ":AUTHOR: ${author-abbrev}\n"
  294. ":JOURNAL: ${journaltitle}\n"
  295. ":DATE: ${date}\n"
  296. ":YEAR: ${year}\n"
  297. ":DOI: ${doi}\n"
  298. ":URL: ${url}\n"
  299. ":END:\n\n"))
  300. (use-package org-ref
  301. :config
  302. (setq org-ref-completion-library 'org-ref-helm-cite
  303. org-ref-get-pdf-filename-function 'org-refg-get-pdf-filename-helm-bibtex
  304. org-ref-default-bibliography dotfiles/bib
  305. org-ref-bibliography-notes dotfiles/notes
  306. org-ref-notes-directory dotfiles/notes
  307. org-ref-notes-function 'orb-edit-notes
  308. 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"))
  309. (use-package org-roam-bibtex
  310. :after (org-roam)
  311. :hook (org-roam-mode . org-roam-bibtex-mode)
  312. :config
  313. (setq orb-preformat-keywords
  314. '("=key=" "title" "url" "file" "author-or-editor" "keywords")))
  315. (add-to-list 'org-roam-capture-templates
  316. '("n" "Notes" plain (function org-roam-capture--get-point)
  317. ""
  318. :file-name "notes/${slug}"
  319. :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"))
  320. (setq org-agenda-files '("~/.local/source/brain/daily/"
  321. "~/.local/source/secrets/org/"))
  322. (dotfiles/leader
  323. "a" '(org-agenda :which-key "Agenda"))
  324. (use-package ox-hugo
  325. :after ox)
  326. (add-to-list 'org-roam-capture-templates
  327. '("b" "Blogging" plain (function org-roam-capture--get-point)
  328. "%?"
  329. :file-name "posts/${slug}"
  330. :head "#+TITLE: ${title}\n#+HUGO_BASE_DIR: ~/.local/source/website\n#+HUGO_SECTION: posts\n"))
  331. (use-package gif-screencast
  332. :custom
  333. (gif-screencast-output-directory "~/.local/source/brain/screen/"))
  334. (dotfiles/leader
  335. "s" '(:ignore t :which-key "Screencast")
  336. "ss" '(gif-screencast-start-or-stop :which-key "Start / Stop")
  337. "sp" '(gif-screencast-toggle-pause :which-key "Pause"))
  338. (use-package ox-reveal
  339. :after ox
  340. :custom (org-reveal-root "https://cdn.jsdelivr.net/reveal.js/3.9.2/"))
  341. (add-to-list 'org-roam-capture-templates
  342. '("p" "Presentation" plain (function org-roam-capture--get-point)
  343. "%?"
  344. :file-name "slides/${slug}"
  345. :head "#+TITLE: ${title}\n"))
  346. (use-package lsp-mode
  347. :custom (gc-cons-threshold 1000000000)
  348. (lsp-idle-delay 0.500))
  349. (use-package lsp-ui
  350. :custom (lsp-ui-doc-position 'at-point)
  351. (lsp-ui-doc-delay 0.500))
  352. (use-package projectile
  353. :config
  354. (setq projectile-project-search-path '("~/.local/source"))
  355. (projectile-mode))
  356. (use-package password-store
  357. :custom (password-store-dir "~/.local/source/passwords"))
  358. (dotfiles/leader
  359. "p" '(:ignore t :which-key "Passwords")
  360. "pp" '(password-store-copy :which-key "Copy")
  361. "pr" '(password-store-rename :which-key "Rename")
  362. "pg" '(password-store-generate :which-key "Generate"))
  363. (use-package dap-mode)
  364. (use-package company)
  365. (use-package company-lsp)
  366. (use-package ccls
  367. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  368. (lambda () (require 'ccls) (lsp))))
  369. ;; (use-package python-mode
  370. ;; :hook (python-mode . lsp)
  371. ;; :config (require 'dap-python)
  372. ;; :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  373. ;; (dap-python-executable "python3") ;; Same as above.
  374. ;; (dap-python-debugger 'debugpy))
  375. ;; (use-package rustic)
  376. ;; (use-package go-mode
  377. ;; :hook (go-mode . lsp))
  378. ;; (defun dotfiles/go-hook ()
  379. ;; (add-hook 'before-save-hook #'lsp-format-buffer t t)
  380. ;; (add-hook 'before-save-hook #'lsp-organize-imports t t))
  381. ;; (add-hook 'go-mode-hook #'dotfiles/go-hook)