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.

830 lines
24 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
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
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. #+TITLE: Dotfiles
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+ROAM_KEY: https://github.com/chayward1/dotfiles
  5. #+begin_example
  6. ^^ @@@@@@@@@
  7. ^^ ^^ @@@@@@@@@@@@@@@
  8. @@@@@@@@@@@@@@@@@@ ^^
  9. @@@@@@@@@@@@@@@@@@@@
  10. ~~~~ ~~ ~~~~~ ~~~~~~~~ ~~ &&&&&&&&&&&&&&&&&&&& ~~~~~~~ ~~~~~~~~~~~ ~~~
  11. ~ ~~ ~ ~ ~~~~~~~~~~~~~~~~~~~~ ~ ~~ ~~ ~
  12. ~ ~~ ~~ ~~ ~~ ~~~~~~~~~~~~~ ~~~~ ~ ~~~ ~ ~~~ ~ ~~
  13. ~ ~~ ~ ~ ~~~~~~ ~~ ~~~ ~~ ~ ~~ ~~ ~
  14. ~ ~ ~ ~ ~ ~~ ~~~~~~ ~ ~~ ~ ~~
  15. ~ ~ ~ ~ ~~ ~ ~
  16. #+end_example
  17. Immutable GNU Emacs dotfiles, inspired by Doom, built for Liberty.
  18. + 100% Literate
  19. + 100% Immutable
  20. + 100% Reproducible
  21. #+begin_src emacs-lisp :tangle ~/.local/source/dotfiles/init.el :results silent
  22. (defun dotfiles/tangle (dir)
  23. "Recursively tangle the Org files within a directory."
  24. (interactive)
  25. (let ((org-files (directory-files-recursively dir "org")))
  26. (dolist (f org-files)
  27. (org-babel-tangle-file f))))
  28. #+end_src
  29. * Core
  30. :PROPERTIES:
  31. :header-args: :tangle ~/.local/source/dotfiles/init.el :results silent
  32. :END:
  33. Emacs creates a lot of files relative to ~user-emacs-directory~, these files are not part of this immutable configuration and do not belong in the emacs directory.
  34. #+begin_src emacs-lisp
  35. (defvar dotfiles/home user-emacs-directory)
  36. #+end_src
  37. How can we solve this issue?
  38. #+begin_src emacs-lisp
  39. (defvar dotfiles/cache "~/.cache/emacs")
  40. #+end_src
  41. Shortly after initialization, before most packages are loaded, we change the value to ~dotfiles/cache~.
  42. #+begin_src emacs-lisp
  43. (setq user-emacs-directory dotfiles/cache)
  44. #+end_src
  45. Because this project uses version-control, we can disable more unwanted features:
  46. + Lock files
  47. + Backup files
  48. #+begin_src emacs-lisp
  49. (setq create-lockfiles nil
  50. make-backup-files nil)
  51. #+end_src
  52. ** Packages
  53. Download and install packages using [[https://github.com/raxod502/straight.el][straight.el]], a functional package manager that integrates with =use-package=, giving us more control over where packages are sourced from.
  54. + Use the development branch
  55. + Integrate with ~use-package~
  56. Apply the configurations prior to bootstrapping the package manager, by setting (writing) to the variables that =straight= will ultimately read from.
  57. #+begin_src emacs-lisp
  58. (setq straight-repository-branch "develop"
  59. straight-use-package-by-default t)
  60. #+end_src
  61. Bootstrap the package manager, downloading, installing, or configuring depending on the state of the configuration. All packages are downloaded and built from source, and can be pinned to specific git commit hashes.
  62. #+begin_src emacs-lisp
  63. (defvar bootstrap-version)
  64. (let ((bootstrap-file
  65. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  66. (bootstrap-version 5))
  67. (unless (file-exists-p bootstrap-file)
  68. (with-current-buffer
  69. (url-retrieve-synchronously
  70. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  71. 'silent 'inhibit-cookies)
  72. (goto-char (point-max))
  73. (eval-print-last-sexp)))
  74. (load bootstrap-file nil 'nomessage))
  75. #+end_src
  76. Complete the integration with ~use-package~ by installing it with =straight=.
  77. #+begin_src emacs-lisp
  78. (straight-use-package 'use-package)
  79. #+end_src
  80. ** Cleanup
  81. Despite having our *stateful* and *immutable* configurations seperate, it's good practice to make efforts to reduce the trash created by Emacs.
  82. Install [[https://github.com/emacscollective/no-littering][no-littering]] to reduce the files created by Emacs.
  83. #+begin_src emacs-lisp
  84. (use-package no-littering)
  85. #+end_src
  86. Emacs' default user interface is horrendous, but with less than 10 lines of code we can change that.
  87. #+begin_src emacs-lisp
  88. (setq inhibit-startup-message t)
  89. (global-prettify-symbols-mode)
  90. (scroll-bar-mode -1)
  91. (menu-bar-mode -1)
  92. (tool-bar-mode -1)
  93. (tooltip-mode -1)
  94. #+end_src
  95. ** Babel
  96. *Organize your plain life in plain text*
  97. [[https://orgmode.org][Org-mode]] is one of the hallmark features of Emacs, and provides the basis for my Literate Programming platform. It's essentially a markdown language with rich features for project management, scheduling, development, and writing. It's hard to convey everything within its capabilities.
  98. + [[https://orgmode.org/worg/org-contrib/babel/languages/index.html][Babel languages]]
  99. + [[https://orgmode.org/manual/Structure-Templates.html][Structure templates]]
  100. #+begin_src emacs-lisp
  101. (use-package org
  102. :hook
  103. (org-mode . (lambda ()
  104. (org-indent-mode)
  105. (visual-line-mode 1)
  106. (variable-pitch-mode 1)))
  107. :config
  108. (setq org-ellipsis " ▾"
  109. org-log-done 'time
  110. org-log-into-drawer t
  111. org-src-preserve-indentation t)
  112. (org-babel-do-load-languages
  113. 'org-babel-load-languages
  114. '((shell . t)
  115. (python . t)
  116. (emacs-lisp . t)))
  117. (require 'org-tempo)
  118. (add-to-list 'org-structure-template-alist '("s" . "src"))
  119. (add-to-list 'org-structure-template-alist '("q" . "quote"))
  120. (add-to-list 'org-structure-template-alist '("e" . "example"))
  121. (add-to-list 'org-structure-template-alist '("sh" . "src shell"))
  122. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  123. (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")))
  124. #+end_src
  125. ** Keys
  126. Make the =ESC= key quit (most) prompts, instead of the default =C-g=.
  127. #+begin_src emacs-lisp
  128. (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
  129. #+end_src
  130. Functionality like =completion= and =hints= can be delayed to avoid popups for common manuevers. Adjust this value to your personal taste.
  131. #+begin_src emacs-lisp
  132. (defvar dotfiles/idle 0.0)
  133. #+end_src
  134. Download [[https://github.com/justbur/emacs-which-key][which-key]], a package that displays the current incomplete keybinding input in a mini-buffer, showing available completion options.
  135. #+begin_src emacs-lisp
  136. (use-package which-key
  137. :diminish which-key-mode
  138. :init (which-key-mode)
  139. :config (setq which-key-idle-delay dotfiles/idle))
  140. #+end_src
  141. Avoid the infamous *Emacs pinky* by binding =SPC= as a leader key, utilizing the thumb instead of the weaker pinky finger. You may change this value if you want to use something else.
  142. #+begin_src emacs-lisp
  143. (defvar dotfiles/leader-key "SPC")
  144. #+end_src
  145. Implement the *leader* key mentioned above using [[https://github.com/noctuid/general.el][general.el]], letting us easily configure prefixed keybindings in a much cleaner manner than the default methods.
  146. #+begin_src emacs-lisp
  147. (use-package general
  148. :config
  149. (general-create-definer dotfiles/leader
  150. :states '(normal motion)
  151. :keymaps 'override
  152. :prefix dotfiles/leader-key))
  153. #+end_src
  154. Use [[https://github.com/abo-abo/hydra][hydra]] for transient keybindings sharing a common prefix.
  155. #+begin_src emacs-lisp
  156. (use-package hydra)
  157. #+end_src
  158. *** Evil
  159. After a few hour with =vim= I knew it was game over, I cannot even think of another way I would feel comfortable editing text. Luckily, there exist packages to emulate this within Emacs.
  160. https://evil.readthedocs.io/en/latest/index.html
  161. + Extendable VI layer for Emacs
  162. + Disable default keybindings
  163. #+begin_src emacs-lisp
  164. (use-package evil
  165. :init (setq evil-want-integration t
  166. evil-want-keybinding nil)
  167. :config (evil-mode 1))
  168. #+end_src
  169. https://github.com/emacs-evil/evil-collection
  170. + Community keybindings for =evil-mode=
  171. #+begin_src emacs-lisp
  172. (use-package evil-collection
  173. :after evil
  174. :config (evil-collection-init))
  175. #+end_src
  176. https://github.com/redguardtoo/evil-nerd-commenter
  177. + Toggle comments with =M-;=
  178. #+begin_src emacs-lisp
  179. (use-package evil-nerd-commenter
  180. :bind ("M-;" . evilnc-comment-or-uncomment-lines))
  181. #+end_src
  182. *** Shortcuts
  183. Again cherry picked from =Doom=, I want to continue utilizing the muscle memory I have developed from a year of mainlining the framework.
  184. + Find files =SPC . (period)=
  185. + Close buffers with =SPC / (slash)=
  186. + Switch buffers with =SPC , (comma)=
  187. #+begin_src emacs-lisp
  188. (dotfiles/leader
  189. "," '(switch-to-buffer :which-key "Buffer")
  190. "/" '(kill-buffer-and-window :which-key "Close")
  191. "." '(find-file :which-key "File"))
  192. #+end_src
  193. **** Quit
  194. Quit emacs with =SPC q=.
  195. + Saving =q=
  196. + Without =w=
  197. + Frame (daemon) =f=
  198. #+begin_src emacs-lisp
  199. (dotfiles/leader
  200. "q" '(:ignore t :which-key "Quit")
  201. "qq" '(save-buffers-kill-emacs :which-key "Save")
  202. "qw" '(kill-emacs :which-key "Now")
  203. "qf" '(delete-frame :which-key "Frame"))
  204. #+end_src
  205. **** Windows
  206. Window management with =SPC w=.
  207. + Swap with =w=
  208. + Close with =c=
  209. + Motions with =h,j,k,l=
  210. + Split with =s + <MOTION>=
  211. #+begin_src emacs-lisp
  212. (dotfiles/leader
  213. "w" '(:ignore t :which-key "Window")
  214. "ww" '(window-swap-states :which-key "Swap")
  215. "wc" '(delete-window :which-key "Close")
  216. "wh" '(windmove-left :which-key "Left")
  217. "wj" '(windmove-down :which-key "Down")
  218. "wk" '(windmove-up :which-key "Up")
  219. "wl" '(windmove-right :which-key "Right")
  220. "ws" '(:ignore t :which-key "Split")
  221. "wsj" '(split-window-below :which-key "Down")
  222. "wsl" '(split-window-right :which-key "Right"))
  223. #+end_src
  224. * Editor
  225. :PROPERTIES:
  226. :header-args: :tangle ~/.local/source/dotfiles/init.el :results silent
  227. :END:
  228. *Bring Emacs out of the eighties*
  229. ** Git
  230. Another hallmark feature is [[https://github.com/magit/magit][Magit]], a complete git porcelain within Emacs.
  231. #+begin_src emacs-lisp
  232. (use-package magit
  233. :custom (magit-display-buffer-function
  234. #'magit-display-buffer-same-window-except-diff-v1))
  235. #+end_src
  236. Work directly with github issues / pull requests using [[https://github.com/magit/forge][Forge]].
  237. + Requires a valid ~$GITHUB_TOKEN~
  238. #+begin_src emacs-lisp
  239. (use-package forge)
  240. #+end_src
  241. Open the *status* page for the current repository with =SPC g=.
  242. #+begin_src emacs-lisp
  243. (dotfiles/leader
  244. "g" '(magit-status :which-key "Magit"))
  245. #+end_src
  246. ** Shell
  247. While not a traditional terminal emulator, =eshell= provides me with all of the functionality I expect and require from one. Some users may be left wanting more, I would recommend they look into =vterm=.
  248. https://github.com/zwild/eshell-prompt-extras
  249. + Enable lambda shell prompt
  250. #+begin_src emacs-lisp
  251. (use-package eshell-prompt-extras
  252. :config (setq eshell-highlight-prompt nil
  253. eshell-prompt-function 'epe-theme-lambda))
  254. #+end_src
  255. Open an =eshell= buffer with =SPC e=.
  256. #+begin_src emacs-lisp
  257. (dotfiles/leader
  258. "e" '(eshell :which-key "Shell"))
  259. #+end_src
  260. ** Files
  261. Emacs' can feel more modern when icon-fonts are installed and prioritized. I feel that this makes navigation of folders much faster, given that file types may be quickly identified by their corresponding icons.
  262. https://github.com/domtronn/all-the-icons.el
  263. + Collects various icon fonts
  264. #+begin_src emacs-lisp
  265. (use-package all-the-icons)
  266. #+end_src
  267. https://github.com/jtbm37/all-the-icons-dired
  268. + Integration with dired
  269. #+begin_src emacs-lisp
  270. (use-package all-the-icons-dired
  271. :hook (dired-mode . all-the-icons-dired-mode))
  272. #+end_src
  273. When opening =dired=, I don't want to have to press =RET= twice to navigate to the current directory. This can be avoided with ~dired-jump~, included in the =dired-x= package shipped with =dired=.
  274. #+begin_src emacs-lisp
  275. (require 'dired-x)
  276. #+end_src
  277. By default =dired= will create a new buffer everytime you press =RET= over a directory. In my workflow this leads to many unwanted =dired= buffers that have to be cleaned up manually. [[https://github.com/crocket/dired-single][Dired-single]] lets us reuse the same dired buffer.
  278. + Move up a directory with =h=
  279. + Open a single buffer with =l=
  280. #+begin_src emacs-lisp
  281. (use-package dired-single
  282. :config
  283. (evil-collection-define-key 'normal 'dired-mode-map
  284. "h" 'dired-single-up-directory
  285. "l" 'dired-single-buffer))
  286. #+end_src
  287. Open a dired buffer with =SPC d=.
  288. #+begin_src emacs-lisp
  289. (dotfiles/leader
  290. "d" '(dired-jump :which-key "Dired"))
  291. #+end_src
  292. ** Fonts
  293. Configure the system font with a single ~font-family~ and define the size, of which variations to the font size are relative to this value.
  294. #+begin_src emacs-lisp
  295. (defvar dotfiles/font "Fira Code")
  296. (defvar dotfiles/font-size 96)
  297. #+end_src
  298. Write out to all *3* of Emacs' default font faces.
  299. #+begin_src emacs-lisp
  300. (set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size)
  301. (set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size)
  302. (set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size)
  303. #+end_src
  304. Define a transient keybinding for scaling the text.
  305. #+begin_src emacs-lisp
  306. (defhydra hydra-text-scale (:timeout 4)
  307. "Scale"
  308. ("j" text-scale-increase "Increase")
  309. ("k" text-scale-decrease "Decrease")
  310. ("f" nil "Finished" :exit t))
  311. #+end_src
  312. Increase the font size in buffers with =SPC f=.
  313. + Increase =j=
  314. + Decrease =k=
  315. + Finish =f=
  316. #+begin_src emacs-lisp
  317. (dotfiles/leader
  318. "f" '(hydra-text-scale/body :which-key "Font"))
  319. #+end_src
  320. ** Lines
  321. Relative line numbers are important when using =VI= emulation keys. You can prefix most commands with a *number*, allowing you to jump up / down by a line count.
  322. #+begin_example
  323. 5:
  324. 4:
  325. 3:
  326. 2:
  327. 1:
  328. 156: << CURRENT LINE >>
  329. 1:
  330. 2:
  331. 3:
  332. 4:
  333. 5:
  334. #+end_example
  335. https://github.com/emacsmirror/linum-relative
  336. + Integrate with ~display-line-numbers-mode~ for performance
  337. #+begin_src emacs-lisp
  338. (use-package linum-relative
  339. :init (setq linum-relative-backend
  340. 'display-line-numbers-mode)
  341. :config (linum-relative-global-mode))
  342. #+end_src
  343. https://github.com/Fanael/rainbow-delimiters
  344. + Colourize nested parenthesis
  345. #+begin_src emacs-lisp
  346. (use-package rainbow-delimiters
  347. :hook (prog-mode . rainbow-delimiters-mode))
  348. #+end_src
  349. ** Themes
  350. Bring Emacs' out of the eighties by cherry picking a few modules from =Doom=.
  351. https://github.com/hlissner/emacs-doom-themes
  352. + Modern colour themes
  353. #+begin_src emacs-lisp
  354. (use-package doom-themes
  355. :init (load-theme 'doom-moonlight t))
  356. #+end_src
  357. Load a theme with =SPC t=.
  358. #+begin_src emacs-lisp
  359. (dotfiles/leader
  360. "t" '(load-theme t nil :which-key "Theme"))
  361. #+end_src
  362. https://github.com/seagle0128/doom-modeline
  363. + Elegant status bar / modeline
  364. #+begin_src emacs-lisp
  365. (use-package doom-modeline
  366. :init (doom-modeline-mode 1)
  367. :custom ((doom-modeline-height 16)))
  368. #+end_src
  369. * Writing
  370. :PROPERTIES:
  371. :header-args: :tangle ~/.local/source/dotfiles/init.el :results silent
  372. :END:
  373. I am using [[https://orgmode.org][Org-mode]] extensively for writing projects for different purposes. Improvements beyond what are required for my Literate Programming platform include:
  374. [[https://github.com/integral-dw/org-superstar-mode][Org-superstar-mode]] for making headline stars more *super*.
  375. #+begin_src emacs-lisp
  376. (use-package org-superstar
  377. :hook (org-mode . org-superstar-mode))
  378. #+end_src
  379. ** Mail
  380. #+begin_src emacs-lisp
  381. (add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
  382. #+end_src
  383. #+begin_src emacs-lisp
  384. (use-package mu4e
  385. :config
  386. (setq mu4e-change-filenames-when-moving t
  387. mu4e-update-interval (* 5 60) ;; Every 5 minutes.
  388. mu4e-get-mail-command "mbsync -a"
  389. mu4e-maildir "~/.cache/mail"
  390. mu4e-compose-signature
  391. (concat "Chris Hayward\n"
  392. "https://chrishayward.xyz\n"))
  393. ;; Ensure plain text scales for all devices.
  394. (setq mu4e-compose-format-flowed t)
  395. ;; GPG signing key for outbound mail.
  396. (setq mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  397. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  398. (setq message-send-mail-function 'smtpmail-send-it)
  399. ;; Configure mail account(s).
  400. (setq mu4e-contexts
  401. (list
  402. ;; Main
  403. ;; chris@chrishayward.xyz
  404. (make-mu4e-context
  405. :name "Main"
  406. :match-func
  407. (lambda (msg)
  408. (when msg
  409. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  410. :vars
  411. '((user-full-name . "Christopher James Hayward")
  412. (user-mail-address . "chris@chrishayward.xyz")
  413. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  414. (smtpmail-smtp-service . 587)
  415. (smtpmail-stream-type . starttls))))))
  416. #+end_src
  417. #+begin_src emacs-lisp
  418. (dotfiles/leader
  419. "m" '(mu4e :which-key "Mail"))
  420. #+end_src
  421. ** Brain
  422. [[https://github.com/org-roam/org-roam][Org-roam]] is a rudimentary roam replica built on =Org mode=.
  423. #+begin_src emacs-lisp
  424. (use-package org-roam
  425. :hook (after-init . org-roam-mode)
  426. :custom (org-roam-directory "~/.local/source/brain"))
  427. #+end_src
  428. [[https://github.com/org-roam/org-roam-server][Org-roam-server]] is a web application that visualizes the =Org roam= database, available when Emacs' running at [[http://localhost:8080][localhost:8080]].
  429. #+begin_src emacs-lisp
  430. (use-package org-roam-server
  431. :hook (org-roam-mode . org-roam-server-mode))
  432. #+end_src
  433. Configure keybindings behind =SPC r=.
  434. + Find with =f=
  435. + Buffer with =b=
  436. + Capture with =c=
  437. + Dailies with =d=
  438. #+begin_src emacs-lisp
  439. (dotfiles/leader
  440. "r" '(:ignore t :which-key "Roam")
  441. "rf" '(org-roam-find-file :which-key "Find")
  442. "rb" '(org-roam-buffer-toggle-display :which-key "Buffer")
  443. "rc" '(org-roam-capture :which-key "Capture")
  444. "rd" '(:ignore t :which-key "Dailies")
  445. "rdd" '(org-roam-dailies-find-date :which-key "Date")
  446. "rdt" '(org-roam-dailies-find-today :which-key "Today")
  447. "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  448. "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  449. #+end_src
  450. Configure the default capture template for new topics.
  451. #+begin_src emacs-lisp
  452. (setq org-roam-capture-templates
  453. '(("d" "Default" plain (function org-roam-capture--get-point)
  454. "%?"
  455. :file-name "${slug}"
  456. :head "#+TITLE: ${title}\n"
  457. :unnarrowed t)))
  458. #+end_src
  459. Configure the default capture template for daily entries.
  460. #+begin_src emacs-lisp
  461. (setq org-roam-dailies-capture-templates
  462. '(("d" "Default" entry (function org-roam-capture--get-point)
  463. "* %?"
  464. :file-name "daily/%<%Y-%m-%d>"
  465. :head "#+TITLE: %<%Y-%m-%d>\n")))
  466. #+end_src
  467. ** Agenda
  468. Configure agenda sources.
  469. + Dailies ~~/.local/source/brain/daily/~
  470. + Secrets ~~/.local/source/secrets/org/~
  471. #+begin_src emacs-lisp
  472. (setq org-agenda-files '("~/.local/source/brain/daily/"
  473. "~/.local/source/secrets/org/"))
  474. #+end_src
  475. Open an agenda buffer with =SPC a=.
  476. #+begin_src emacs-lisp
  477. (dotfiles/leader
  478. "a" '(org-agenda :which-key "Agenda"))
  479. #+end_src
  480. ** Blogging
  481. I use [[https://gohugo.io][Hugo]] for my personal [[https://chrishayward.xyz][website]], which I write in =Org-mode= before compiling to =hugo-markdown=.
  482. [[https://github.com/kaushalmodi/ox-hugo][Ox-hugo]], configured for =one-post-per-file= is my technique for managing my blog.
  483. #+begin_src emacs-lisp
  484. (use-package ox-hugo
  485. :after ox)
  486. #+end_src
  487. Creaate a capture template for blog posts in the =posts= sub directory.
  488. #+begin_src emacs-lisp
  489. (add-to-list 'org-roam-capture-templates
  490. '("b" "Blogging" plain (function org-roam-capture--get-point)
  491. "%?"
  492. :file-name "posts/${slug}"
  493. :head "#+TITLE: ${title}\n#+HUGO_BASE_DIR: ../\n#+HUGO_SECTION: ./\n"))
  494. #+end_src
  495. ** Screencasts
  496. Create screencasts with =one-frame-per-action= GIF recording via [[https://github.com/takaxp/emacs-gif-screencast][emacs-gif-screencast]].
  497. + Can be paused / resumed
  498. + High quality images
  499. + Optimized size
  500. It requires the installation of ~scrot~ and ~convert~ from the =ImageMagick= library.
  501. #+begin_src emacs-lisp
  502. (use-package gif-screencast
  503. :custom
  504. (gif-screencast-output-directory "~/.local/source/brain/screen/"))
  505. #+end_src
  506. Screencast controls behind =SPC p=.
  507. + Start / stop with =s=
  508. + Pause with =p=
  509. #+begin_src emacs-lisp
  510. (dotfiles/leader
  511. "p" '(:ignore t :which-key "Screencast")
  512. "ps" '(gif-screencast-start-or-stop :which-key "Start / Stop")
  513. "pp" '(gif-screencast-toggle-pause :which-key "Pause"))
  514. #+end_src
  515. ** Presentations
  516. Produce high quality presentations that work anywhere with =HTML/JS= and the [[https://revealjs.com][Reveal.js]] package.
  517. [[https://github.com/hexmode/ox-reveal][Ox-reveal]], configured to use a =cdn= allows us to produce ones that are not dependent on a local version of =Reveal.js=.
  518. #+begin_src emacs-lisp
  519. (use-package ox-reveal
  520. :after ox
  521. :custom (org-reveal-root "https://cdn.jsdelivr.net/reveal.js/3.9.2/"))
  522. #+end_src
  523. Create a capture template for presentations stored in the =slides= sub directory.
  524. #+begin_src emacs-lisp
  525. (add-to-list 'org-roam-capture-templates
  526. '("p" "Presentation" plain (function org-roam-capture--get-point)
  527. "%?"
  528. :file-name "slides/${slug}"
  529. :head "#+TITLE: ${title}\n"))
  530. #+end_src
  531. * Development
  532. :PROPERTIES:
  533. :header-args: :tangle ~/.local/source/dotfiles/init.el :results silent
  534. :END:
  535. An IDE like experience (or better) can be achieved in Emacs using two *Microsoft* open source initiatives.
  536. Turn Emacs into an *IDE* (or better) with the [[https://microsoft.github.io/language-server-protocol/][Language Server Protocol]], an open source initiative from *Microsoft* for the *VSCode* editor.
  537. [[https://emacs-lsp.github.io/lsp-mode/][Lsp-mode]] brings support for language servers into Emacs.
  538. #+begin_src emacs-lisp
  539. (use-package lsp-mode
  540. :custom (gc-cons-threshold 1000000000)
  541. (lsp-idle-delay 0.500))
  542. #+end_src
  543. https://emacs-lsp.github.io/lsp-ui/
  544. + UI improvements for =lsp-mode=
  545. #+begin_src emacs-lisp
  546. (use-package lsp-ui
  547. :custom (lsp-ui-doc-position 'at-point)
  548. (lsp-ui-doc-delay 0.500))
  549. #+end_src
  550. ** Passwords
  551. Pass makes managing passwords extremely easy, encrypring them in a file structure and providing easy commands for generating, modify, and copying passwords. =password-store.el= provides a wrapper for the functionality within Emacs.
  552. #+begin_src emacs-lisp
  553. (use-package password-store
  554. :custom (password-store-dir "~/.local/source/passwords"))
  555. #+end_src
  556. ** Debugging
  557. Handled through the [[https://microsoft.github.io/debug-adapter-protocol/][Debug Adapter Protocol]], an open source initiative from *Microsoft* for the *VSCode* editor.
  558. [[https://emacs-lsp.github.io/dap-mode/][Dap-mode]] adds support for the protocol to Emacs.
  559. #+begin_src emacs-lisp
  560. (use-package dap-mode)
  561. #+end_src
  562. ** Completion
  563. Text completion framework via =company= aka *Complete Anything*.
  564. http://company-mode.github.io/
  565. + Integrate with =lsp-mode=
  566. #+begin_src emacs-lisp
  567. (use-package company)
  568. (use-package company-lsp)
  569. #+end_src
  570. ** Languages
  571. Support for individual languages are implemented here.
  572. *** C/C++
  573. Full *IDE* experience for Python within Emacs.
  574. + Completion, jumps via =lsp-mode=
  575. + Debugging via =dap-mode=
  576. Install the =ccls= language server.
  577. + https://github.com/MaskRay/ccls
  578. #+begin_src emacs-lisp
  579. (use-package ccls
  580. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  581. (lambda () (require 'ccls) (lsp))))
  582. #+end_src
  583. *** Python
  584. Full *IDE* experience for Python within Emacs.
  585. + Completion, jumps via =lsp-mode=
  586. + Debugging via =dap-mode=
  587. Install the =pyls= language server.
  588. #+begin_src shell :tangle no
  589. pip install --user "python-language-server[all]"
  590. #+end_src
  591. https://www.emacswiki.org/emacs/PythonProgrammingInEmacs
  592. + Built in mode
  593. #+begin_src emacs-lisp
  594. (use-package python-mode
  595. :hook (python-mode . lsp)
  596. :config (require 'dap-python)
  597. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  598. (dap-python-executable "python3") ;; Same as above.
  599. (dap-python-debugger 'debugpy))
  600. #+end_src
  601. *** Rust
  602. Full *IDE* experience for Rust within Emacs.
  603. + Completion via =lsp-mode=
  604. + Debugging via =dap-mode=
  605. https://github.com/brotzeit/rustic
  606. + Install via ~lsp-install-server~
  607. #+begin_src shell :tangle no
  608. rustup default nightly
  609. #+end_src
  610. #+begin_src emacs-lisp
  611. (use-package rustic)
  612. #+end_src
  613. *** Go
  614. Full *IDE* experience for Rust within Emacs.
  615. + Completion via =lsp-mode=
  616. + Debugging via =dap-mode=
  617. Install the =gopls= language server.
  618. #+begin_src sh :tangle no
  619. GO111MODULE=on go get golang.org/x/tools/gopls@latest
  620. #+end_src
  621. #+begin_src emacs-lisp
  622. (use-package go-mode
  623. :hook (go-mode . lsp))
  624. #+end_src