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.

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