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.

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