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.

1376 lines
42 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
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. #+SUBTITLE: I showed you my source code, pls respond
  3. #+AUTHOR: Christopher James Hayward
  4. #+EMAIL: chris@chrishayward.xyz
  5. #+ROAM_KEY: https://github.com/chayward1/dotfiles/
  6. #+ATTR_ORG: :width 420px
  7. #+ATTR_HTML: :width 420px
  8. #+ATTR_LATEX: :width 420px
  9. [[./docs/images/desktop-alt.png]]
  10. Immutable GNU Emacs dotfiles. Built for Life, Liberty, and the Open Road.
  11. + 100% Literate
  12. + 100% Immutable
  13. + 100% Reproducible
  14. Heavily inspired by [[https://github.com/hlissner/doom-emacs][Doom Emacs]] and [[https://youtube.com/c/SystemCrafters][System Crafters]].
  15. * Init
  16. :PROPERTIES:
  17. :header-args: :tangle init.el
  18. :END:
  19. Although later versions of Emacs introduce =early-init.el=, it's not used in this configuration for two reasons:
  20. + It's not required due to the modularity
  21. + Maintaining support for older versions
  22. Assuming you have completed all of the following tasks prior to proceeding further:
  23. 1. Imported the =secrets=
  24. 2. Initialized the =passwords=
  25. 3. Defined the =host= file
  26. 4. Created all required symbolic links
  27. Launch emacs: ~emacs -mm --debug-init~
  28. ** Options
  29. Here's a complete list of all of the options configurable for each host, and their default values. If a host configuration does not exist, these values will be used in place.
  30. 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.
  31. #+begin_src emacs-lisp
  32. (defvar dotfiles/font
  33. "Fira Code"
  34. "Unified system font family, used on all font faces.")
  35. #+end_src
  36. #+begin_src emacs-lisp
  37. (defvar dotfiles/font-size
  38. 96
  39. "Unified font size, of which all variations are relative to.")
  40. #+end_src
  41. Used by the desktop module to find the appropriate browser.
  42. #+begin_src emacs-lisp
  43. (defvar dotfiles/browser
  44. (getenv "BROWSER")
  45. "The default browser used by the system.")
  46. #+end_src
  47. All of the available modules are defined in the ~dotfiles/modules-available~ constant.
  48. #+begin_src emacs-lisp
  49. (defconst dotfiles/modules-available
  50. '(core editor desktop writing projects interface)
  51. "All of the available modules for hosts to load.")
  52. #+end_src
  53. Add the modules you want to initialize to the ~dotfiles/modules~ variable.
  54. #+begin_src emacs-lisp
  55. (defvar dotfiles/modules
  56. dotfiles/modules-available
  57. "Enabled modules, modify this in your host configuration.")
  58. #+end_src
  59. Specify the emacs home, and the cache directory.
  60. #+begin_src emacs-lisp
  61. (defvar dotfiles/home
  62. user-emacs-directory
  63. "Original value of `user-emacs-directory'.")
  64. #+end_src
  65. Used to seperate the immutable configuration from the stateful package files.
  66. #+begin_src emacs-lisp
  67. (defvar dotfiles/cache
  68. (expand-file-name "~/.cache/emacs")
  69. "Where `user-emacs-directory' will be redirected.")
  70. #+end_src
  71. Functionality like =completion= and =hints= can be delayed to avoid popups for common manuevers.
  72. #+begin_src emacs-lisp
  73. (defvar dotfiles/idle
  74. 0.0
  75. "Length of time to wait before offering completions.")
  76. #+end_src
  77. Required for the all powerful leader key.
  78. #+begin_src emacs-lisp
  79. (defvar dotfiles/leader-key
  80. "SPC"
  81. "Custom leader key for custom actions.")
  82. #+end_src
  83. The desktop module requires the global leader key to be set.
  84. #+begin_src emacs-lisp
  85. (defvar dotfiles/leader-key-global
  86. (concat "C-" dotfiles/leader-key)
  87. "Global leader key available everywhere.")
  88. #+end_src
  89. Define where the source repositories are stored, for integration with the *Projects* module.
  90. #+begin_src emacs-lisp
  91. (defvar dotfiles/projects
  92. (expand-file-name "~/.local/source/")
  93. "Location where source code projects are stored.")
  94. #+end_src
  95. Where the password store is located.
  96. #+begin_src emacs-lisp
  97. (defvar dotfiles/passwords
  98. (expand-file-name "~/.password-store/")
  99. "Directory containing the password store.")
  100. #+end_src
  101. ** Startup
  102. The host configuration is loaded (if it exist) using the systems name.
  103. #+begin_src emacs-lisp
  104. ;; Load the host configuration.
  105. (let ((host-file (concat dotfiles/home "/hosts/" system-name ".el")))
  106. (when (file-exists-p host-file)
  107. (load-file host-file)))
  108. #+end_src
  109. Load all of the enabled modules:
  110. #+begin_src emacs-lisp
  111. ;; Load the enabled modules.
  112. (dolist (m dotfiles/modules)
  113. (let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".el")))
  114. (when (file-exists-p mod-file)
  115. (load-file mod-file))))
  116. #+end_src
  117. * Hosts
  118. Each host system that runs Emacs has a file defined in the =hosts/= sub directory, following the pattern of ~$HOSTNAME.el~. All of the configurations are defined within this file, the values of which are read from by the other modules during startup and installation. This does *not* cover hosts that are controlled via =TRAMP=, as that will be covered in another section.
  119. ** Virtualbox
  120. :PROPERTIES:
  121. :header-args: :tangle hosts/virtualbox.el
  122. :END:
  123. The first configuration, which was built using the Ubuntu 20.04 LTS server edition. I decided to incorporate =flatpaks= into this build.
  124. #+begin_src emacs-lisp
  125. (setq dotfiles/browser "flatpak run org.mozilla.firefox")
  126. #+end_src
  127. ** Acernitro
  128. :PROPERTIES:
  129. :header-args: :tangle hosts/acernitro.el
  130. :END:
  131. #+begin_src emacs-lisp
  132. (setq dotfiles/browser "flatpak run org.mozilla.firefox")
  133. #+end_src
  134. This machine has a screen with a very high =DPI=, requiring modification to ~dotfiles/font-size~.
  135. #+begin_src emacs-lisp
  136. ;; (setq dotfiles/font-size 144)
  137. #+end_src
  138. * Modules
  139. Breaking down the project into logical units or chapters to keep the code more maintainable and organized. This is also a fundemental requirement to achieve the goal of modularity. Incorporating just the =core= module on a build server to build literate programming projects is just one example of what can be achieved.
  140. ** Core
  141. :PROPERTIES:
  142. :header-args: :tangle modules/core.el :results silent
  143. :END:
  144. Minimal configuration to make Emacs usable for my own personal workflow. This does very little in the ways of improving the visuals, only removing what is included by default and not required.
  145. *** Startup
  146. 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. How can we solve this issue? Shortly after initialization, before most packages are loaded, we change the value to ~dotfiles/cache~. I elaborate more on the technique in my post [[https://chrishayward.xyz/posts/immutable-emacs/][Immutable Emacs]].
  147. #+begin_src emacs-lisp
  148. (setq user-emacs-directory dotfiles/cache)
  149. #+end_src
  150. Because this project uses version-control, we can disable more unwanted features:
  151. + Lock files
  152. + Backup files
  153. #+begin_src emacs-lisp
  154. (setq create-lockfiles nil
  155. make-backup-files nil)
  156. #+end_src
  157. *** Packages
  158. 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.
  159. + Use the development branch
  160. + Integrate with ~use-package~
  161. Apply the configurations prior to bootstrapping the package manager, by setting (writing) to the variables that =straight= will ultimately read from.
  162. #+begin_src emacs-lisp
  163. (setq straight-repository-branch "develop"
  164. straight-use-package-by-default t)
  165. #+end_src
  166. 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.
  167. #+begin_src emacs-lisp
  168. (defvar bootstrap-version)
  169. (let ((bootstrap-file
  170. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  171. (bootstrap-version 5))
  172. (unless (file-exists-p bootstrap-file)
  173. (with-current-buffer
  174. (url-retrieve-synchronously
  175. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  176. 'silent 'inhibit-cookies)
  177. (goto-char (point-max))
  178. (eval-print-last-sexp)))
  179. (load bootstrap-file nil 'nomessage))
  180. #+end_src
  181. Complete the integration with ~use-package~ by installing it with =straight=.
  182. #+begin_src emacs-lisp
  183. (straight-use-package 'use-package)
  184. #+end_src
  185. *** Cleanup
  186. Despite having our *stateful* and *immutable* configurations seperate, it's good practice to make efforts to reduce the trash created by Emacs.
  187. Install [[https://github.com/emacscollective/no-littering][no-littering]] to reduce the files created by Emacs.
  188. #+begin_src emacs-lisp
  189. (use-package no-littering)
  190. #+end_src
  191. Emacs' default user interface is horrendous, but with less than 10 lines of code we can change that.
  192. #+begin_src emacs-lisp
  193. (setq inhibit-startup-message t)
  194. (global-prettify-symbols-mode)
  195. (scroll-bar-mode -1)
  196. (menu-bar-mode -1)
  197. (tool-bar-mode -1)
  198. (tooltip-mode -1)
  199. #+end_src
  200. *** Babel
  201. *Organize your plain life in plain text*
  202. [[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.
  203. + [[https://orgmode.org/worg/org-contrib/babel/languages/index.html][Babel languages]]
  204. + [[https://orgmode.org/manual/Structure-Templates.html][Structure templates]]
  205. #+begin_src emacs-lisp
  206. (use-package org
  207. :hook (org-mode . (lambda ()
  208. (org-indent-mode)
  209. (visual-line-mode 1)
  210. (variable-pitch-mode 1)))
  211. :custom (org-ellipsis " ▾")
  212. (org-log-done 'time)
  213. (org-log-into-drawer t)
  214. (org-image-actual-width nil)
  215. (org-directory dotfiles/home)
  216. (org-src-preserve-indentation t)
  217. (org-todo-keywords '((sequence "TODO" "WAIT" "DONE")))
  218. :config (require 'org-tempo)
  219. (add-to-list 'org-structure-template-alist '("s" . "src"))
  220. (add-to-list 'org-structure-template-alist '("q" . "quote"))
  221. (add-to-list 'org-structure-template-alist '("e" . "example"))
  222. (add-to-list 'org-structure-template-alist '("sh" . "src shell"))
  223. (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
  224. (org-babel-do-load-languages 'org-babel-load-languages '((shell . t)
  225. (emacs-lisp . t))))
  226. #+end_src
  227. Build all of the =org= files within a given directory.
  228. #+begin_src emacs-lisp
  229. (defun dotfiles/tangle (dir)
  230. "Recursively tangle the Org files within a directory."
  231. (interactive)
  232. (let ((org-files (directory-files-recursively dir "org")))
  233. (dolist (f org-files)
  234. (org-babel-tangle-file f))))
  235. #+end_src
  236. ** Editor
  237. :PROPERTIES:
  238. :header-args: :tangle modules/editor.el :results silent
  239. :END:
  240. This section contains configuration for improving the editor experience within Emacs.
  241. *** Keys
  242. Make the =ESC= key quit (most) prompts, instead of the default =C-g=.
  243. #+begin_src emacs-lisp
  244. (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
  245. #+end_src
  246. 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.
  247. #+begin_src emacs-lisp
  248. (use-package which-key
  249. :diminish which-key-mode
  250. :custom (which-key-idle-delay dotfiles/idle)
  251. :config (which-key-mode))
  252. #+end_src
  253. 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. [[https://evil.readthedocs.io/en/latest/index.html][evil-mode]] is the extensible VI layer for Emacs.
  254. #+begin_src emacs-lisp
  255. (use-package evil
  256. :custom (evil-want-integration t) ;; Required for `evil-collection'.
  257. (evil-want-keybinding nil) ;; Same as above
  258. :config (evil-mode 1))
  259. #+end_src
  260. Unfortunately the default keybindings are *lacking*, but there is a community curated package [[https://github.com/emacs-evil/evil-collection][evil-collection]], which does a much better job implementing keybindings you would expect to find.
  261. #+begin_src emacs-lisp
  262. (use-package evil-collection
  263. :after evil
  264. :config (evil-collection-init))
  265. #+end_src
  266. Surround text with functions, quotations, and any other symbols using the [[https://github.com/emacs-evil/evil-surround][evil-surround]] package.
  267. #+begin_src emacs-lisp
  268. (use-package evil-surround
  269. :after evil
  270. :config (global-evil-surround-mode 1))
  271. #+end_src
  272. https://github.com/redguardtoo/evil-nerd-commenter
  273. + Toggle comments with =M-;=
  274. #+begin_src emacs-lisp
  275. (use-package evil-nerd-commenter
  276. :after evil
  277. :bind ("M-;" . evilnc-comment-or-uncomment-lines))
  278. #+end_src
  279. Implement the *leader* key using [[https://github.com/noctuid/general.el][general.el]], letting us easily configure prefixed keybindings in a much cleaner manner than the default methods.
  280. #+begin_src emacs-lisp
  281. (use-package general
  282. :after evil
  283. :config
  284. (general-create-definer dotfiles/leader
  285. :states '(normal motion)
  286. :keymaps 'override
  287. :prefix dotfiles/leader-key
  288. :global-prefix dotfiles/leader-key-global))
  289. #+end_src
  290. Use [[https://github.com/abo-abo/hydra][hydra]] for transient keybindings sharing a common prefix.
  291. #+begin_src emacs-lisp
  292. (use-package hydra
  293. :defer t)
  294. #+end_src
  295. *** Help
  296. Run helper functions with =SPC h=.
  297. + Packages =p=
  298. + Variables =v=
  299. + Functions =f=
  300. #+begin_src emacs-lisp
  301. (dotfiles/leader
  302. "h" '(:ignore t :which-key "Help")
  303. "hp" '(describe-package :which-key "Package")
  304. "hv" '(describe-variable :which-key "Variable")
  305. "hf" '(describe-function :which-key "Function"))
  306. #+end_src
  307. *** Files
  308. 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.
  309. https://github.com/domtronn/all-the-icons.el
  310. + Collects various icon fonts
  311. #+begin_src emacs-lisp
  312. (use-package all-the-icons)
  313. #+end_src
  314. https://github.com/jtbm37/all-the-icons-dired
  315. + Integration with dired
  316. #+begin_src emacs-lisp
  317. (use-package all-the-icons-dired
  318. :hook (dired-mode . all-the-icons-dired-mode))
  319. #+end_src
  320. 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=.
  321. #+begin_src emacs-lisp
  322. (require 'dired-x)
  323. #+end_src
  324. 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.
  325. + Move up a directory with =h=
  326. + Open a single buffer with =l=
  327. #+begin_src emacs-lisp
  328. (use-package dired-single
  329. :config (evil-collection-define-key 'normal 'dired-mode-map
  330. "h" 'dired-single-up-directory
  331. "l" 'dired-single-buffer))
  332. #+end_src
  333. Open a dired buffer with =SPC d=.
  334. #+begin_src emacs-lisp
  335. (dotfiles/leader
  336. "d" '(dired-jump :which-key "Dired"))
  337. #+end_src
  338. *** Shell
  339. 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=.
  340. https://github.com/zwild/eshell-prompt-extras
  341. + Enable lambda shell prompt
  342. #+begin_src emacs-lisp
  343. (use-package eshell-prompt-extras
  344. :custom (eshell-highlight-prompt nil)
  345. (eshell-prompt-function 'epe-theme-lambda))
  346. #+end_src
  347. Open an =eshell= buffer with =SPC e=.
  348. #+begin_src emacs-lisp
  349. (dotfiles/leader
  350. "e" '(eshell :which-key "Shell"))
  351. #+end_src
  352. *** Source
  353. Another hallmark feature is [[https://github.com/magit/magit][Magit]], a complete git porcelain within Emacs.
  354. #+begin_src emacs-lisp
  355. (use-package magit
  356. :custom (magit-display-buffer-function
  357. #'magit-display-buffer-same-window-except-diff-v1))
  358. #+end_src
  359. Work directly with github issues / pull requests using [[https://github.com/magit/forge][Forge]].
  360. + Requires a valid ~$GITHUB_TOKEN~
  361. #+begin_src emacs-lisp
  362. (use-package forge
  363. :after magit)
  364. #+end_src
  365. Open the *status* page for the current repository with =SPC g=.
  366. #+begin_src emacs-lisp
  367. (dotfiles/leader
  368. "g" '(magit-status :which-key "Magit"))
  369. #+end_src
  370. *** Windows
  371. Window management with =SPC w=.
  372. + Swap with =w=
  373. + Close with =c=
  374. + Motions with =h,j,k,l=
  375. + Split with =s + <MOTION>=
  376. #+begin_src emacs-lisp
  377. (dotfiles/leader
  378. "w" '(:ignore t :which-key "Window")
  379. "ww" '(window-swap-states :which-key "Swap")
  380. "wc" '(delete-window :which-key "Close")
  381. "wh" '(windmove-left :which-key "Left")
  382. "wj" '(windmove-down :which-key "Down")
  383. "wk" '(windmove-up :which-key "Up")
  384. "wl" '(windmove-right :which-key "Right")
  385. "ws" '(:ignore t :which-key "Split")
  386. "wsj" '(split-window-below :which-key "Down")
  387. "wsl" '(split-window-right :which-key "Right"))
  388. #+end_src
  389. *** Shortcuts
  390. Implement a few shortcut bindings, cherry picked from Doom emacs.
  391. + Close buffers with =SPC c=
  392. + Find files with =SPC . (period)=
  393. #+begin_src emacs-lisp
  394. (dotfiles/leader
  395. "." '(find-file :which-key "Files")
  396. "c" '(kill-buffer-and-window :which-key "Close"))
  397. #+end_src
  398. Quit emacs with =SPC q=.
  399. + Saving =q=
  400. + Without =w=
  401. + Frame (daemon) =f=
  402. #+begin_src emacs-lisp
  403. (dotfiles/leader
  404. "q" '(:ignore t :which-key "Quit")
  405. "qq" '(save-buffers-kill-emacs :which-key "Save")
  406. "qw" '(kill-emacs :which-key "Now")
  407. "qf" '(delete-frame :which-key "Frame"))
  408. #+end_src
  409. Place runtime tweaks behind =SPC t=.
  410. #+begin_src emacs-lisp
  411. (dotfiles/leader
  412. "t" '(:ignore t :which-key "Tweaks"))
  413. #+end_src
  414. ** Desktop
  415. :PROPERTIES:
  416. :header-args: :tangle modules/desktop.el :results silent
  417. :END:
  418. I use Emacs as a Desktop Environment with the [[https://github.com/ch11ng/exwm][exwm]] package. It allows Emacs to function as a complete tiling window manager for =X11=. My workflow includes launching the window manager with =xinitrc=, without the use of a display manager, controlling *everything* within Emacs.
  419. #+begin_src conf :tangle config/xinitrc
  420. exec dbus-launch --exit-with-session flatpak run emacs -mm --debug-init
  421. #+end_src
  422. *** Email
  423. Plain text email delivered via mu, mu4e and mbsync. I run my own email server, so your configuration may differ from mine. This is the ~mbsyncrc~ file I use to synchronize my local mail with my server. This is required for mu4e in Emacs.
  424. #+begin_src conf :tangle config/mbsyncrc
  425. IMAPStore xyz-remote
  426. Host mail.chrishayward.xyz
  427. User chris@chrishayward.xyz
  428. PassCmd "pass chrishayward.xyz/chris"
  429. SSLType IMAPS
  430. MaildirStore xyz-local
  431. Path ~/.cache/mail/
  432. Inbox ~/.cache/mail/inbox
  433. SubFolders Verbatim
  434. Channel xyz
  435. Master :xyz-remote:
  436. Slave :xyz-local:
  437. Patterns * !Archives
  438. Create Both
  439. Expunge Both
  440. SyncState *
  441. #+end_src
  442. The system typically expects to find this file at ~$HOME/.mbsyncrc~, but you may also specify a custom path if launching the command using arguments. I chose to symlink the default location to my repository.
  443. #+begin_src shell :tangle no
  444. mbsync -a
  445. mu index --maildir="~/.cache/mail"
  446. #+end_src
  447. Once the mail is being synchronized, and the mail has been indexed with =mu=, it's time to install the required packages for Emacs.
  448. + Update every 5 minutes
  449. + Scale text for all devices
  450. + Sign outbound mail with GPG key
  451. + Configure mail account(s)
  452. #+begin_src emacs-lisp
  453. (use-package mu4e
  454. :load-path "/usr/share/emacs/site-lisp/mu4e"
  455. :custom (mu4e-maildir "~/.cache/mail")
  456. (mu4e-update-interval (* 5 60))
  457. (mu4e-get-mail-command "mbsync -a")
  458. (mu4e-compose-format-flowed t)
  459. (mu4e-change-filenames-when-moving t)
  460. (message-send-mail-function 'smtpmail-send-it)
  461. (mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  462. (mu4e-compose-signature (concat "Chris Hayward\n"
  463. "https://chrishayward.xyz\n"))
  464. :config
  465. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  466. (setq mu4e-contexts
  467. (list
  468. ;; Main
  469. ;; chris@chrishayward.xyz
  470. (make-mu4e-context
  471. :name "Main"
  472. :match-func
  473. (lambda (msg)
  474. (when msg
  475. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  476. :vars
  477. '((user-full-name . "Christopher James Hayward")
  478. (user-mail-address . "chris@chrishayward.xyz")
  479. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  480. (smtpmail-smtp-service . 587)
  481. (smtpmail-stream-type . starttls))))))
  482. #+end_src
  483. Use [[https://github.com/iqbalansari/mu4e-alert][mu4e-alert]] to give us desktop notifications about incoming mail.
  484. #+begin_src emacs-lisp
  485. (use-package mu4e-alert
  486. :after mu4e
  487. :custom (mu4e-alert-set-default-style 'libnotify)
  488. :config (mu4e-alert-enable-notifications)
  489. (mu4e-alert-enable-mode-line-display))
  490. #+end_src
  491. Create a keybinding to open the mail dashboard with =SPC m=.
  492. #+begin_src emacs-lisp
  493. (dotfiles/leader
  494. "m" '(mu4e :which-key "Mail"))
  495. #+end_src
  496. *** Browser
  497. Write out the ~$BROWSER~ environment variable.
  498. #+begin_src emacs-lisp
  499. (setenv "BROWSER" dotfiles/browser)
  500. #+end_src
  501. Launch a browser with =SPC b=.
  502. #+begin_src emacs-lisp
  503. ;; (dotfiles/leader
  504. ;; "b" '(dotfiles/run-in-background dotfiles/browser :which-key "Browser"))
  505. #+end_src
  506. *** Startup
  507. When launching into a session, if the display server is not running then =startx= should be invoked, to run the window manager.
  508. #+begin_src sh :tangle config/profile
  509. if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
  510. exec startx
  511. fi
  512. #+end_src
  513. *** Methods
  514. Define a method to run an external process, allowing us to launch any application on a new process without interferring with Emacs.
  515. #+begin_src emacs-lisp
  516. (defun dotfiles/run (command)
  517. "Run an external process."
  518. (interactive (list (read-shell-command "λ ")))
  519. (start-process-shell-command command nil command))
  520. #+end_src
  521. Some methods must be called and applied to the current call process in order to function correctly with Emacs hooks.
  522. #+begin_src emacs-lisp
  523. (defun dotfiles/run-in-background (command)
  524. (let ((command-parts (split-string command "[ ]+")))
  525. (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
  526. #+end_src
  527. Place keybindings for executing shell commands behind =SPC x=.
  528. + Run shell commands with =x=
  529. + Run async shell commands with =z=
  530. #+begin_src emacs-lisp
  531. (dotfiles/leader
  532. "x" '(:ignore t :which-key "Run")
  533. "xx" '(dotfiles/run :which-key "Run")
  534. "xz" '(async-shell-command :which-key "Async"))
  535. #+end_src
  536. *** Displays
  537. When the window manager first launches the ~init-hook~ will be called, this allows us to define some custom logic when it's initialized.
  538. + Display time and date
  539. + Display battery info (if available)
  540. In my personal configuration, I do not want the battery or time displayed within Emacs when it's not running as desktop environment because that information is typically already available.
  541. #+begin_src emacs-lisp
  542. (defun dotfiles/init-hook ()
  543. (exwm-workspace-switch-create 1)
  544. (setq display-time-and-date t)
  545. (display-battery-mode 1)
  546. (display-time-mode 1))
  547. #+end_src
  548. Using =autorandr= with pre configured profiles, switching screens (AKA hot plugging) is also handled through a hook.
  549. #+begin_src emacs-lisp
  550. (defun dotfiles/update-display ()
  551. (dotfiles/run-in-background "autorandr --change --force"))
  552. #+end_src
  553. *** Configuration
  554. Connect our custom hooks and configure the input keys, a custom layer for defining which keys are captured by Emacs, and which are passed through to =X= applications.
  555. + Enable =randr= support
  556. + Pass through to Emacs
  557. + =M-x= to Emacs
  558. + =C-g= to Emacs
  559. + =C-SPC= to Emacs
  560. + Bindings with =S= (Super / Win)
  561. + Reset =S-r=
  562. + Launch =S-&=
  563. + Workspace =S-[1..9]=
  564. #+begin_src emacs-lisp
  565. (use-package exwm
  566. :demand t
  567. :custom (exwm-input-prefix-keys
  568. '(?\M-x
  569. ?\C-g
  570. ?\C-\ ))
  571. (exwm-input-global-keys
  572. `(([?\s-r] . exwm-reset)
  573. ,@(mapcar (lambda (i)
  574. `(,(kbd (format "s-%d" i)) .
  575. (lambda ()
  576. (interactive)
  577. (exwm-workspace-switch-create ,i))))
  578. (number-sequence 1 9))))
  579. :config (require 'exwm-randr)
  580. (exwm-randr-enable)
  581. (add-hook 'exwm-init-hook #'dotfiles/init-hook)
  582. (add-hook 'exwm-randr-screen-change-hook #'dotfiles/update-display)
  583. (dotfiles/update-display)
  584. (exwm-enable))
  585. #+end_src
  586. ** Writing
  587. :PROPERTIES:
  588. :header-args: :tangle modules/writing.el :results silent
  589. :END:
  590. I am using [[https://orgmode.org][Org-mode]] extensively for writing projects for different purposes. Most of the improvements are done in the *Core* module for the Literate programming configuration. [[https://github.com/integral-dw/org-superstar-mode][Org-superstar-mode]] for making headline stars more *super*.
  591. #+begin_src emacs-lisp
  592. (use-package org-superstar
  593. :after org
  594. :hook (org-mode . org-superstar-mode))
  595. #+end_src
  596. I use [[https://gohugo.io][Hugo]] for my personal [[https://chrishayward.xyz][website]], which I write in =Org-mode= before compiling to =hugo-markdown=. [[https://github.com/kaushalmodi/ox-hugo][Ox-hugo]], configured for =one-post-per-file= is my technique for managing my blog.
  597. #+begin_src emacs-lisp
  598. (use-package ox-hugo
  599. :after ox)
  600. #+end_src
  601. Produce high quality presentations that work anywhere with =HTML/JS= and the [[https://revealjs.com][Reveal.js]] package. [[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=.
  602. #+begin_src emacs-lisp
  603. (use-package ox-reveal
  604. :after ox
  605. :custom (org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js"))
  606. #+end_src
  607. *** Roam
  608. Download and install [[https://orgroam.com][org-roam]], a plain text knowledge management system for Emacs. Organize the capture templates, this allows me to quickly dictate where each new item should be placed.
  609. + ~posts/~ contains blog posts
  610. + ~notes/~ contains cited notes on others' work
  611. + ~slides/~ contains presentations / screencasts
  612. #+begin_src emacs-lisp
  613. (use-package org-roam
  614. :hook (after-init . org-roam-mode)
  615. :custom (org-roam-directory org-directory)
  616. (org-roam-encrypt-files t)
  617. (org-roam-capture-templates
  618. '(("p" "Post" plain (function org-roam-capture--get-point)
  619. "%?"
  620. :file-name "docs/posts/${slug}"
  621. :unnarrowed t
  622. :head
  623. "
  624. ,#+TITLE: ${title}
  625. ,#+AUTHOR: Christopher James Hayward
  626. ,#+DATE: %<%Y-%m-%d>
  627. ,#+EXPORT_FILE_NAME: ${slug}
  628. ,#+ROAM_KEY: https://chrishayward.xyz/posts/${slug}/
  629. ,#+HUGO_BASE_DIR: ../../website/
  630. ,#+HUGO_AUTO_SET_LASTMOD: t
  631. ,#+HUGO_SECTION: posts
  632. ,#+HUGO_DRAFT: true
  633. ")
  634. ("n" "Notes" plain (function org-roam-capture--get-point)
  635. "%?"
  636. :file-name "docs/notes/${slug}"
  637. :unnarrowed t
  638. :head
  639. "
  640. ,#+TITLE: ${title}
  641. ,#+AUTHOR: Christopher James Hayward
  642. ,#+EXPORT_FILE_NAME: ${slug}
  643. ,#+ROAM_KEY: https://chrishayward.xyz/notes/${slug}/
  644. ,#+HUGO_BASE_DIR: ../../website
  645. ,#+HUGO_AUTO_SET_LASTMOD: t
  646. ,#+HUGO_SECTION: notes
  647. ,#+HUGO_DRAFT: true
  648. ")
  649. ("c" "Course" plain (function org-roam-capture--get-point)
  650. "%?"
  651. :file-name "docs/courses/${slug}"
  652. :unnarrowed t
  653. :head
  654. "
  655. ,#+TITLE: ${title}
  656. ,#+SUBTITLE:
  657. ,#+AUTHOR: Christopher James Hayward
  658. ")
  659. ("s" "Slides" plain (function org-roam-capture--get-point)
  660. "%?"
  661. :file-name "docs/slides/${slug}"
  662. :unnarrowed t
  663. :head
  664. "
  665. ,#+TITLE: ${title}
  666. ,#+AUTHOR: Christopher James Hayward
  667. ,#+REVEAL_ROOT: https://cdn.jsdelivr.net/npm/reveal.js
  668. ")))
  669. (org-roam-dailies-capture-templates
  670. '(("d" "Default" entry (function org-roam-capture--get-point)
  671. "* %?"
  672. :file-name "docs/daily/%<%Y-%m-%d>"
  673. :head
  674. "
  675. ,#+TITLE: %<%Y-%m-%d>
  676. ,#+AUTHOR: Christopher James Hayward
  677. "))))
  678. #+end_src
  679. Place keybindings behind =SPC r=.
  680. + Find with =f=
  681. + Toggle buffer with =b=
  682. + Dailies with =d=
  683. + Arbitrary date with =d=
  684. + Today with =t=
  685. + Tomorrow with =m=
  686. + Yesterday with =y=
  687. #+begin_src emacs-lisp
  688. (dotfiles/leader
  689. "r" '(:ignore t :which-key "Roam")
  690. "rf" '(org-roam-find-file :which-key "Find")
  691. "rb" '(org-roam-buffer-toggle-display :which-key "Buffer")
  692. "rd" '(:ignore t :which-key "Dailies")
  693. "rdd" '(org-roam-dailies-find-date :which-key "Date")
  694. "rdt" '(org-roam-dailies-find-today :which-key "Today")
  695. "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  696. "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  697. #+end_src
  698. Visualize the org-roam database with the server, available when the editor is running at http://localhost:8080
  699. #+begin_src emacs-lisp
  700. (use-package org-roam-server
  701. :hook (org-roam-mode . org-roam-server-mode))
  702. #+end_src
  703. *** Agenda
  704. Override ~org-agenda-file-regexp~ to include =.org.gpg= files.
  705. #+begin_src emacs-lisp
  706. (unless (string-match-p "\\.gpg" org-agenda-file-regexp)
  707. (setq org-agenda-file-regexp
  708. (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?"
  709. org-agenda-file-regexp)))
  710. #+end_src
  711. Configure agenda sources.
  712. #+begin_src emacs-lisp
  713. (setq org-agenda-files '("~/.emacs.d/docs/"
  714. "~/.emacs.d/docs/courses/"
  715. "~/.emacs.d/docs/daily/"))
  716. #+end_src
  717. Open an agenda buffer with =SPC a=.
  718. #+begin_src emacs-lisp
  719. (dotfiles/leader
  720. "a" '(org-agenda :which-key "Agenda"))
  721. #+end_src
  722. *** Images
  723. Create screencasts with =one-frame-per-action= GIF recording via [[https://github.com/takaxp/emacs-gif-screencast][emacs-gif-screencast]].
  724. + Can be paused / resumed
  725. + High quality images
  726. + Optimized size
  727. It requires the installation of ~scrot~, ~gifsicle~, and ~convert~ from the =ImageMagick= library.
  728. #+begin_src emacs-lisp
  729. (use-package gif-screencast
  730. :commands (gif-screencast-start-or-stop gif-screencast-toggle-pause)
  731. :custom (gif-screencast-output-directory (concat dotfiles/home "docs/images/")))
  732. #+end_src
  733. Screencast controls behind =SPC s=.
  734. + Start / stop with =s=
  735. + Pause with =t=
  736. #+begin_src emacs-lisp
  737. (dotfiles/leader
  738. "s" '(:ignore t :which-key "Screencast")
  739. "ss" '(gif-screencast-start-or-stop :which-key "Start / Stop")
  740. "sp" '(gif-screencast-toggle-pause :which-key "Pause"))
  741. #+end_src
  742. ** Projects
  743. :PROPERTIES:
  744. :header-args: :tangle modules/projects.el :results silent
  745. :END:
  746. An IDE like experience (or better) can be achieved in Emacs using two *Microsoft* open source initiatives. 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. [[https://emacs-lsp.github.io/lsp-mode/][lsp-mode]] brings support for language servers into Emacs.
  747. #+begin_src emacs-lisp
  748. (use-package lsp-mode
  749. :commands (lsp lsp-deferred)
  750. :custom (gc-cons-threshold 1000000000)
  751. (lsp-idle-delay 0.500))
  752. #+end_src
  753. [[https://emacs-lsp.github.io/lsp-ui/][lsp-ui]] provides UI improvements for =lsp-mode=.
  754. #+begin_src emacs-lisp
  755. (use-package lsp-ui
  756. :after lsp
  757. :custom (lsp-ui-doc-position 'at-point)
  758. (lsp-ui-doc-delay 0.500))
  759. #+end_src
  760. *** Containers
  761. Use ~docker~ for running containers. Download and install https://github.com/Silex/docker.el, allowing us to manage containers within Emacs.
  762. #+begin_src emacs-lisp
  763. (use-package docker
  764. :commands (docker))
  765. #+end_src
  766. Open the management screen with =SPC k=.
  767. #+begin_src emacs-lisp
  768. (dotfiles/leader
  769. "k" '(docker :which-key "Docker"))
  770. #+end_src
  771. *** Management
  772. Configure [[https://projectile.mx][projectile]], a project interaction library for Emacs. It provides a nice set of features for operating on a project level without introducing external dependencies.
  773. #+begin_src emacs-lisp
  774. (use-package projectile
  775. :custom (projectile-project-search-path '("~/.local/source"))
  776. :config (projectile-mode))
  777. #+end_src
  778. *** Passwords
  779. 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.
  780. #+begin_src emacs-lisp
  781. (use-package password-store
  782. :custom (password-store-dir dotfiles/passwords))
  783. #+end_src
  784. Configure keybindings behind =SPC p=.
  785. + Copy with =p=
  786. + Rename with =r=
  787. + Generate with =g=
  788. #+begin_src emacs-lisp
  789. (dotfiles/leader
  790. "p" '(:ignore t :which-key "Passwords")
  791. "pp" '(password-store-copy :which-key "Copy")
  792. "pr" '(password-store-rename :which-key "Rename")
  793. "pg" '(password-store-generate :which-key "Generate"))
  794. #+end_src
  795. *** Debugging
  796. Handled through the [[https://microsoft.github.io/debug-adapter-protocol/][Debug Adapter Protocol]], an open source initiative from *Microsoft* for the *VSCode* editor.
  797. [[https://emacs-lsp.github.io/dap-mode/][Dap-mode]] adds support for the protocol to Emacs.
  798. #+begin_src emacs-lisp
  799. (use-package dap-mode
  800. :commands (dap-debug))
  801. #+end_src
  802. *** Completion
  803. Text completion framework via =company= aka *Complete Anything*.
  804. http://company-mode.github.io/
  805. + Integrate with =lsp-mode=
  806. #+begin_src emacs-lisp
  807. (use-package company
  808. :after lsp)
  809. (use-package company-lsp
  810. :after (lsp company)
  811. :custom (company-backend 'company-lsp))
  812. #+end_src
  813. *** Languages
  814. Support for individual languages are implemented here.
  815. **** Go
  816. Install the =gopls= language server.
  817. #+begin_src sh :tangle no
  818. GO111MODULE=on go get golang.org/x/tools/gopls@latest
  819. #+end_src
  820. Set the ~GOPATH~ environment variable prior to loading, this allows us to change the default value of ~$HOME/go~ to ~$HOME/.go~.
  821. #+begin_src emacs-lisp
  822. (setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
  823. #+end_src
  824. Additionally, include the =bin= subdirectory of the ~$GOPATH~ in the ~$PATH~ variable, adding compiled golang programs.
  825. #+begin_src emacs-lisp
  826. (setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
  827. #+end_src
  828. Finally we can include the =go-mode= package, integrating it with =lsp=.
  829. #+begin_src emacs-lisp
  830. (use-package go-mode
  831. :hook (go-mode . lsp)
  832. :custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
  833. #+end_src
  834. Apply some custom behaviour before saving:
  835. + Format buffer
  836. + Organize imports
  837. #+begin_src emacs-lisp
  838. (defun dotfiles/go-hook ()
  839. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  840. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  841. #+end_src
  842. #+begin_src emacs-lisp
  843. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  844. #+end_src
  845. Add a golang source code block structure template with ~<go~:
  846. #+begin_src emacs-lisp
  847. (add-to-list 'org-structure-template-alist '("go" . "src go"))
  848. #+end_src
  849. **** C/C++
  850. Install the [[https://github.com/MaskRay/ccls][ccls]] language server, and allow us to create a new structure template for C/C++ with ~<cc~.
  851. #+begin_src emacs-lisp
  852. (use-package ccls
  853. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  854. (lambda ()
  855. (require 'ccls)
  856. (lsp-deferred)))
  857. :config (add-to-list 'org-structure-template-alist '("cc" . "src cc")))
  858. #+end_src
  859. **** Python
  860. Install the =pyls= language server.
  861. #+begin_src shell :tangle no
  862. pip install --user "python-language-server[all]"
  863. #+end_src
  864. [[https://www.emacswiki.org/emacs/PythonProgrammingInEmacs][Python-mode]] is an Emacs built in mode.
  865. + Load the babel language module for Python
  866. + Add a python source code block structure template with ~<py~
  867. #+begin_src emacs-lisp
  868. (use-package python-mode
  869. :hook (python-mode . lsp-deferred)
  870. :config (require 'dap-python)
  871. (add-to-list 'org-src-lang-modes '("python" . python))
  872. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  873. (org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
  874. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  875. (dap-python-executable "python3") ;; Same as above.
  876. (dap-python-debugger 'debugpy))
  877. #+end_src
  878. **** PlantUML
  879. Download and install [[https://plantuml.com][PlantUML]], a text-based markup language for creating UML diagrams.
  880. + Load the babel language module for PlantUML
  881. + Create a structure template with ~<pl~
  882. #+begin_src emacs-lisp
  883. (use-package plantuml-mode
  884. :after org
  885. :custom (plantuml-default-exec-mode 'jar)
  886. (plantuml-jar-path "~/.local/bin/plantuml.jar")
  887. (org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
  888. (org-startup-with-inline-images t)
  889. :config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  890. (add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
  891. (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))
  892. #+end_src
  893. Toggle inline images with =SPC t i=.
  894. #+begin_src emacs-lisp
  895. (dotfiles/leader
  896. "ti" '(org-display-inline-images :which-key "Images"))
  897. #+end_src
  898. ** Interface
  899. :PROPERTIES:
  900. :header-args: :tangle modules/interface.el :results silent
  901. :END:
  902. *Bring Emacs out of the eighties*
  903. *** Ivy
  904. Download and configure [[https://oremacs.com/swiper/][ivy]], a powerful selection menu for Emacs.
  905. #+begin_src emacs-lisp
  906. (use-package ivy
  907. :diminish
  908. :config (ivy-mode 1))
  909. #+end_src
  910. Counsel is a customized set of commands to replace built in completion buffers.
  911. #+begin_src emacs-lisp
  912. (use-package counsel
  913. :after ivy
  914. :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
  915. :config (counsel-mode 1))
  916. #+end_src
  917. Switch buffers with =SPC , (comma)=.
  918. #+begin_src emacs-lisp
  919. (dotfiles/leader
  920. "," '(counsel-switch-buffer :which-key "Buffers"))
  921. #+end_src
  922. Provide more information about each item with [[https://github.com/Yevgnen/ivy-rich][ivy-rich]].
  923. #+begin_src emacs-lisp
  924. (use-package ivy-rich
  925. :after counsel
  926. :init (ivy-rich-mode 1))
  927. #+end_src
  928. *** Fonts
  929. Write out to all *3* of Emacs' default font faces.
  930. #+begin_src emacs-lisp
  931. (set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size)
  932. (set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size)
  933. (set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size)
  934. #+end_src
  935. Define a transient keybinding for scaling the text.
  936. #+begin_src emacs-lisp
  937. (defhydra hydra-text-scale (:timeout 4)
  938. "Scale"
  939. ("j" text-scale-increase "Increase")
  940. ("k" text-scale-decrease "Decrease")
  941. ("f" nil "Finished" :exit t))
  942. #+end_src
  943. Increase the font size in buffers with =SPC t f=.
  944. + Increase =j=
  945. + Decrease =k=
  946. + Finish =f=
  947. #+begin_src emacs-lisp
  948. (dotfiles/leader
  949. "tf" '(hydra-text-scale/body :which-key "Font"))
  950. #+end_src
  951. *** Lines
  952. 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.
  953. #+begin_example
  954. 5:
  955. 4:
  956. 3:
  957. 2:
  958. 1:
  959. 156: << CURRENT LINE >>
  960. 1:
  961. 2:
  962. 3:
  963. 4:
  964. 5:
  965. #+end_example
  966. https://github.com/emacsmirror/linum-relative
  967. + Integrate with ~display-line-numbers-mode~ for performance
  968. #+begin_src emacs-lisp
  969. (use-package linum-relative
  970. :custom (linum-relative-backend 'display-line-numbers-mode)
  971. :config (linum-relative-global-mode))
  972. #+end_src
  973. Add line numbers to the toggles behind =SPC t l=.
  974. #+begin_src emacs-lisp
  975. (dotfiles/leader
  976. "tl" '(linum-relative-global-mode :which-key "Lines"))
  977. #+end_src
  978. https://github.com/Fanael/rainbow-delimiters
  979. + Colourize nested parenthesis
  980. #+begin_src emacs-lisp
  981. (use-package rainbow-delimiters
  982. :hook (prog-mode . rainbow-delimiters-mode))
  983. #+end_src
  984. *** Themes
  985. Cherry pick a few modules from =doom-emacs=. High quality and modern colour themes are provided in the [[https://github.com/hlissner/emacs-doom-themes][doom-themes]] package.
  986. #+begin_src emacs-lisp
  987. (use-package doom-themes
  988. :init (load-theme 'doom-moonlight t))
  989. #+end_src
  990. [[https://github.com/seagle0128/doom-modeline][doom-modeline]] provides an elegant status bar / modeline.
  991. #+begin_src emacs-lisp
  992. (use-package doom-modeline
  993. :custom (doom-modeline-height 16)
  994. :config (doom-modeline-mode 1))
  995. #+end_src
  996. Load a theme with =SPC t t=.
  997. #+begin_src emacs-lisp
  998. (dotfiles/leader
  999. "tt" '(counsel-load-theme t t :which-key "Theme"))
  1000. #+end_src
  1001. *** Ligatures
  1002. Enable font ligatures via [[https://github.com/jming422/fira-code-mode][fira-code-mode]], perform this action *only* when ~Fira Code~ is set as the current font.
  1003. #+begin_src emacs-lisp
  1004. (when (display-graphic-p)
  1005. (use-package fira-code-mode
  1006. :hook (prog-mode org-mode)))
  1007. #+end_src
  1008. Toggle global ligature mode with =SPC t g=.
  1009. #+begin_src emacs-lisp
  1010. (dotfiles/leader
  1011. "tg" '(global-fira-code-mode :which-key "Ligatures"))
  1012. #+end_src
  1013. *** Dashboard
  1014. #+ATTR_ORG: :width 420px
  1015. #+ATTR_HTML: :width 420px
  1016. #+ATTR_LATEX: :width 420px
  1017. [[./docs/images/desktop.png]]
  1018. Present a dashboard when first launching Emacs. Customize the buttons of the navigator:
  1019. + Brain @ http://localhost:8080
  1020. + Homepage @ https://chrishayward.xyz
  1021. + Athabasca @ https://login.athabascau.ca/cas/login
  1022. + Bookshelf @ https://online.vitalsource.com
  1023. #+begin_src emacs-lisp
  1024. (use-package dashboard
  1025. :custom (dashboard-center-content t)
  1026. (dashboard-set-init-info t)
  1027. (dashboard-set-file-icons t)
  1028. (dashboard-set-heading-icons t)
  1029. (dashboard-set-navigator t)
  1030. (dashboard-startup-banner 'logo)
  1031. (dashboard-projects-backend 'projectile)
  1032. (dashboard-items '((projects . 5) (recents . 5) (agenda . 10)))
  1033. (dashboard-navigator-buttons `(((,(all-the-icons-fileicon "brain" :height 1.1 :v-adjust 0.0)
  1034. "Brain" "Knowledge base"
  1035. (lambda (&rest _) (browse-url "http://localhost:8080"))))
  1036. ((,(all-the-icons-material "public" :height 1.1 :v-adjust 0.0)
  1037. "Homepage" "Personal website"
  1038. (lambda (&rest _) (browse-url "https://chrishayward.xyz"))))
  1039. ((,(all-the-icons-faicon "university" :height 1.1 :v-adjust 0.0)
  1040. "Athabasca" "Univeristy login"
  1041. (lambda (&rest _) (browse-url "https://login.athabascau.ca/cas/login"))))
  1042. ((,(all-the-icons-faicon "book" :height 1.1 :v-adjust 0.0)
  1043. "Bookshelf" "Vitalsource bookshelf"
  1044. (lambda (&rest _) (browse-url "https://online.vitalsource.com"))))))
  1045. :config (dashboard-setup-startup-hook))
  1046. #+end_src
  1047. When running in *daemon* mode, ensure that the dashboard is the initial buffer.
  1048. #+begin_src emacs-lisp
  1049. (setq initial-buffer-choice
  1050. (lambda ()
  1051. (get-buffer "*dashboard*")))
  1052. #+end_src