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.

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