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.

875 lines
25 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
  1. #+TITLE: Dotfiles
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :comments org
  5. #+PROPERTY: header-args:shell :tangle no
  6. #+PROPERTY: header-args :results silent :eval no-export
  7. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  8. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  9. #+ATTR_ORG: :width 420px
  10. #+ATTR_HTML: :width 420px
  11. #+ATTR_LATEX: :width 420px
  12. [[./docs/images/desktop-alt.png]]
  13. Immutable GNU Emacs dotfiles. Built for Life, Liberty, and the Open Road.
  14. + 100% Literate
  15. + 100% Immutable
  16. + 100% Reproducible
  17. * Init
  18. :PROPERTIES:
  19. :header-args: :tangle init.el
  20. :END:
  21. Here's a complete list of all of the options configurable for each host, and their default values. All variables prefixed with ~dotfiles/~. If you need to make configurations to another variable, consider creating a new option.
  22. #+begin_src emacs-lisp
  23. (defvar dotfiles/font
  24. "Fira Code"
  25. "Unified system font family.")
  26. (defvar dotfiles/font-size
  27. 96
  28. "Unified system font size.")
  29. (defvar dotfiles/browser
  30. (getenv "BROWSER")
  31. "Default system web browser.")
  32. (defvar dotfiles/language
  33. (getenv "LANG")
  34. "Default system dictionary language.")
  35. (defconst dotfiles/modules-p
  36. '(core editor email desktop writing projects interface)
  37. "All of the available modules.")
  38. (defvar dotfiles/modules
  39. dotfiles/modules-p
  40. "All of the enabled modules.")
  41. (defvar dotfiles/home
  42. user-emacs-directory
  43. "Original value of `user-emacs-directory'.")
  44. (defvar dotfiles/cache
  45. (expand-file-name "~/.cache/emacs")
  46. "Redirection target of `user-emacs-directory'.")
  47. (defvar dotfiles/idle
  48. 0.0
  49. "Delay time before offering suggestions and completions.")
  50. (defvar dotfiles/leader-key
  51. "SPC"
  52. "All powerful leader key.")
  53. (defvar dotfiles/leader-key-global
  54. (concat "C-" dotfiles/leader-key)
  55. "Global prefix for the leader key.")
  56. (defvar dotfiles/projects
  57. (expand-file-name "~/.local/source/")
  58. "Location of source code projects.")
  59. (defvar dotfiles/passwords
  60. (expand-file-name "~/.password-store/")
  61. "Location of local password store.")
  62. (defvar dotfiles/public-key
  63. "37AB1CB72B741E478CA026D43025DCBD46F81C0F"
  64. "GPG key to encrypt org files for.")
  65. #+end_src
  66. * Hosts
  67. Override any of the available options configurations in a host file. Here's some examples to get started:
  68. + [[file:hosts/localhost.org][Termux]]
  69. + [[file:hosts/raspberry.org][Raspberry]]
  70. + [[file:hosts/acernitro.org][Acernitro]]
  71. + [[file:hosts/virtualbox.org][Virtualbox]]
  72. Begin the process by loading any host specific overrides. The host configuration tangles, and loads (if it exist) using the systems name.
  73. #+begin_src emacs-lisp
  74. (let ((host-file (concat dotfiles/home "/hosts/" system-name ".org")))
  75. (when (file-exists-p host-file)
  76. (org-babel-load-file host-file)))
  77. #+end_src
  78. * Modules
  79. Breaking down the project into logical units or chapters to keep the code more maintainable and organized. This is also a fundamental requirement to achieve the goal of modularity. Here are all of the available modules, also listed in the variable ~dotfiles/modules-p~.
  80. + [[file:modules/core.org][Core]]
  81. + [[file:modules/editor.org][Editor]]
  82. + [[file:modules/email.org][Email]]
  83. + [[file:modules/desktop.org][Desktop]]
  84. By default all of the modules will load, override the variable ~dotfiles/modules~ in a host configuration to override this.
  85. #+begin_src emacs-lisp
  86. (dolist (m dotfiles/modules)
  87. (let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".org")))
  88. (when (file-exists-p mod-file)
  89. (org-babel-load-file mod-file))))
  90. #+end_src
  91. ** Writing
  92. :PROPERTIES:
  93. :header-args: :tangle modules/writing.el
  94. :END:
  95. 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. Encrypt files using symmetric key encryption via PGP. This enables my workflow of storing my personal notes anywhere. Emacs can cache the gpg password if you trust your session.
  96. #+begin_src emacs-lisp
  97. (setq epa-file-select-keys 2
  98. epa-file-cache-passphrase-for-symmetric-encryption t
  99. epa-file-encrypt-to dotfiles/public-key)
  100. #+end_src
  101. Download and install [[https://github.com/integral-dw/org-superstar-mode][org-superstar-mode]] for making headline stars more *super*.
  102. #+begin_src emacs-lisp
  103. (use-package org-superstar
  104. :after org
  105. :hook (org-mode . org-superstar-mode))
  106. #+end_src
  107. *** Roam
  108. #+ATTR_ORG: :width 420px
  109. #+ATTR_HTML: :width 420px
  110. #+ATTR_LATEX: :width 420px
  111. [[./docs/images/2021-02-13-example-roam.png]]
  112. Download and install [[https://orgroam.com][org-roam]], a plain text knowledge management system for Emacs.
  113. #+begin_src emacs-lisp
  114. (use-package org-roam
  115. :hook (after-init . org-roam-mode)
  116. :custom (org-roam-directory org-directory)
  117. (org-roam-encrypt-files t)
  118. (org-roam-capture-templates '())
  119. (org-roam-dailies-capture-templates
  120. '(("d" "Default" entry (function org-roam-capture--get-point)
  121. "* %?"
  122. :file-name "docs/daily/%<%Y-%m-%d>"
  123. :head
  124. "
  125. ,#+TITLE: %<%Y-%m-%d>
  126. ,#+AUTHOR: Christopher James Hayward
  127. "))))
  128. #+end_src
  129. Place keybindings behind =SPC r=.
  130. + Find with =f=
  131. + Toggle buffer with =b=
  132. + Dailies with =d=
  133. + Arbitrary date with =d=
  134. + Today with =t=
  135. + Tomorrow with =m=
  136. + Yesterday with =y=
  137. #+begin_src emacs-lisp
  138. (dotfiles/leader
  139. "r" '(:ignore t :which-key "Roam")
  140. "rf" '(org-roam-find-file :which-key "Find")
  141. "rb" '(org-roam-buffer-toggle-display :which-key "Buffer")
  142. "rd" '(:ignore t :which-key "Dailies")
  143. "rdd" '(org-roam-dailies-find-date :which-key "Date")
  144. "rdt" '(org-roam-dailies-find-today :which-key "Today")
  145. "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  146. "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  147. #+end_src
  148. Visualize the org-roam database with the server, available when the editor is running at http://localhost:8080
  149. #+begin_src emacs-lisp
  150. (use-package org-roam-server
  151. :hook (org-roam-mode . org-roam-server-mode))
  152. #+end_src
  153. *** Hugo
  154. 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 content.
  155. #+begin_src emacs-lisp
  156. (use-package ox-hugo
  157. :after ox)
  158. #+end_src
  159. *** Posts
  160. Add a capture template for creating new blog posts.
  161. #+begin_src emacs-lisp
  162. (with-eval-after-load 'org-roam
  163. (add-to-list 'org-roam-capture-templates
  164. '("p" "Post" plain (function org-roam-capture--get-point)
  165. "%?"
  166. :file-name "docs/posts/${slug}"
  167. :unnarrowed t
  168. :head
  169. "
  170. ,#+TITLE: ${title}
  171. ,#+AUTHOR: Christopher James Hayward
  172. ,#+DATE: %<%Y-%m-%d>
  173. ,#+EXPORT_FILE_NAME: ${slug}
  174. ,#+ROAM_KEY: https://chrishayward.xyz/posts/${slug}/
  175. ,#+HUGO_BASE_DIR: ../
  176. ,#+HUGO_AUTO_SET_LASTMOD: t
  177. ,#+HUGO_SECTION: posts
  178. ,#+HUGO_DRAFT: true
  179. ")))
  180. #+end_src
  181. *** Notes
  182. Add a capture template for creating blog posts and notes on other peoples content / published works.
  183. #+begin_src emacs-lisp
  184. (with-eval-after-load 'org-roam
  185. (add-to-list 'org-roam-capture-templates
  186. '("n" "Notes" plain (function org-roam-capture--get-point)
  187. "%?"
  188. :file-name "docs/notes/${slug}"
  189. :unnarrowed t
  190. :head
  191. "
  192. ,#+TITLE: ${title}
  193. ,#+AUTHOR: Christopher James Hayward
  194. ,#+EXPORT_FILE_NAME: ${slug}
  195. ,#+ROAM_KEY: https://chrishayward.xyz/notes/${slug}/
  196. ,#+HUGO_BASE_DIR: ../
  197. ,#+HUGO_AUTO_SET_LASTMOD: t
  198. ,#+HUGO_SECTION: notes
  199. ,#+HUGO_DRAFT: true
  200. ")))
  201. #+end_src
  202. *** Slides
  203. 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=.
  204. #+begin_src emacs-lisp
  205. (use-package ox-reveal
  206. :after ox
  207. :custom (org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js"))
  208. #+end_src
  209. Create a capture template for creating slides quickly, with our desired configuration.
  210. #+begin_src emacs-lisp
  211. (with-eval-after-load 'org-roam
  212. (add-to-list 'org-roam-capture-templates
  213. '("s" "Slides" plain (function org-roam-capture--get-point)
  214. "%?"
  215. :file-name "docs/slides/${slug}"
  216. :unnarrowed t
  217. :head
  218. "
  219. ,#+TITLE: ${title}
  220. ,#+AUTHOR: Christopher James Hayward
  221. ,#+EMAIL: chris@chrishayward.xyz
  222. ,#+REVEAL_ROOT: https://cdn.jsdelivr.net/npm/reveal.js
  223. ,#+REVEAL_THEME: serif
  224. ,#+EXPORT_FILE_NAME: ${slug}
  225. ,#+OPTIONS: reveal_title_slide:nil
  226. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  227. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  228. ")))
  229. #+end_src
  230. *** Agenda
  231. #+ATTR_ORG: :width 420px
  232. #+ATTR_HTML: :width 420px
  233. #+ATTR_LATEX: :width 420px
  234. [[./docs/images/2021-02-13-example-agenda.gif]]
  235. Override ~org-agenda-file-regexp~ to include =.org.gpg= files.
  236. #+begin_src emacs-lisp
  237. (unless (string-match-p "\\.gpg" org-agenda-file-regexp)
  238. (setq org-agenda-file-regexp
  239. (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?"
  240. org-agenda-file-regexp)))
  241. #+end_src
  242. Create a capture template for courses.
  243. #+begin_src emacs-lisp
  244. (with-eval-after-load 'org-roam
  245. (add-to-list 'org-roam-capture-templates
  246. '("c" "Course" plain (function org-roam-capture--get-point)
  247. "%?"
  248. :file-name "docs/courses/${slug}"
  249. :unnarrowed t
  250. :head
  251. "
  252. ,#+TITLE: ${title}
  253. ,#+SUBTITLE:
  254. ,#+AUTHOR: Christopher James Hayward
  255. ,#+EMAIL: chris@chrishayward.xyz
  256. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  257. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  258. ")))
  259. #+end_src
  260. Configure agenda sources.
  261. #+begin_src emacs-lisp
  262. (setq org-agenda-files '("~/.emacs.d/docs/"
  263. "~/.emacs.d/docs/courses/"
  264. "~/.emacs.d/docs/daily/"))
  265. #+end_src
  266. Open an agenda buffer with =SPC a=.
  267. #+begin_src emacs-lisp
  268. (dotfiles/leader
  269. "a" '(org-agenda :which-key "Agenda"))
  270. #+end_src
  271. *** Images
  272. Capture screenshots with [[https://github.com/tecosaur/screenshot][screenshot.el]].
  273. #+begin_src emacs-lisp
  274. (use-package screenshot
  275. :commands (screenshot))
  276. #+end_src
  277. Create screencasts with =one-frame-per-action= GIF recording via [[https://github.com/takaxp/emacs-gif-screencast][emacs-gif-screencast]].
  278. + Pause / Resume
  279. + High Quality
  280. + Optimized
  281. It requires the installation of ~scrot~, ~gifsicle~, and ~convert~ from the =ImageMagick= library.
  282. #+begin_src emacs-lisp
  283. (use-package gif-screencast
  284. :commands (gif-screencast-start-or-stop gif-screencast-toggle-pause)
  285. :custom (gif-screencast-output-directory (concat dotfiles/home "docs/images/")))
  286. #+end_src
  287. Place keybindings behind =SPC s=.
  288. + Screenshot with =s=
  289. + Screencast with =c=
  290. #+begin_src emacs-lisp
  291. (dotfiles/leader
  292. "s" '(:ignore t :which-key "Screen")
  293. "ss" '(screenshot :which-key "Screenshot")
  294. "sc" '(gif-screencast-start-or-stop :which-key "Screencast"))
  295. #+end_src
  296. *** Grammar
  297. I use [[https://github.com/bnbeckwith/writegood-mode][writegood-mode]] to find common writing problems such as cliches and poor wording. Grammarly for the peons!
  298. #+begin_src emacs-lisp
  299. (use-package writegood-mode
  300. :after org
  301. :config (writegood-mode))
  302. #+end_src
  303. Toggle ~writegood~ mode with =SPC t w=.
  304. #+begin_src emacs-lisp
  305. (dotfiles/leader
  306. "tw" '(writegood-mode :which-key "Grammar"))
  307. #+end_src
  308. *** Spelling
  309. Use the built in =ispell= package to add spell checking features to buffers.
  310. #+begin_src emacs-lisp
  311. (use-package ispell
  312. :after org
  313. :custom (ispell-dictionary dotfiles/lang))
  314. #+end_src
  315. Toggle highlighting within buffers with =SPC t s=.
  316. #+begin_src emacs-lisp
  317. (dotfiles/leader
  318. "ts" '(flyspell-buffer :which-key "Spelling"))
  319. #+end_src
  320. ** Projects
  321. :PROPERTIES:
  322. :header-args: :tangle modules/projects.el
  323. :END:
  324. An IDE like experience (or better) can be achieved in Emacs using two *Microsoft* open source initiatives.
  325. + [[https://microsoft.github.io/language-server-protocol/][Language Server Protocol]]
  326. + [[https://microsoft.github.io/debug-adapter-protocol/][Debug Adapter Protocol]]
  327. Add support for language servers with [[https://emacs-lsp.github.io/lsp-mode/][lsp-mode]].
  328. #+begin_src emacs-lisp
  329. (use-package lsp-mode
  330. :commands (lsp lsp-deferred)
  331. :custom (lsp-idle-delay (* 5 dotfiles/idle)))
  332. #+end_src
  333. [[https://emacs-lsp.github.io/lsp-ui/][lsp-ui]] provides UI improvements for =lsp-mode=.
  334. #+begin_src emacs-lisp
  335. (use-package lsp-ui
  336. :after lsp
  337. :custom (lsp-ui-doc-position 'at-point)
  338. (lsp-ui-doc-delay 0.500))
  339. #+end_src
  340. [[https://emacs-lsp.github.io/dap-mode/][Dap-mode]] adds support for the debug adapter protocol to Emacs.
  341. #+begin_src emacs-lisp
  342. (use-package dap-mode
  343. :commands (dap-debug))
  344. #+end_src
  345. *** Containers
  346. Use ~docker~ for running containers. Download and install https://github.com/Silex/docker.el, allowing us to manage containers within Emacs.
  347. #+begin_src emacs-lisp
  348. (use-package docker
  349. :commands (docker))
  350. #+end_src
  351. Open the management screen with =SPC k=.
  352. #+begin_src emacs-lisp
  353. (dotfiles/leader
  354. "k" '(docker :which-key "Docker"))
  355. #+end_src
  356. *** Management
  357. 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.
  358. #+begin_src emacs-lisp
  359. (use-package projectile
  360. :custom (projectile-project-search-path '("~/.local/source"))
  361. :config (projectile-mode))
  362. #+end_src
  363. *** Completion
  364. Text completion framework via =company= aka *Complete Anything*.
  365. http://company-mode.github.io/
  366. + Integrate with =lsp-mode=
  367. #+begin_src emacs-lisp
  368. (use-package company
  369. :after lsp)
  370. (use-package company-lsp
  371. :after (lsp company)
  372. :custom (company-backend 'company-lsp))
  373. #+end_src
  374. *** Passwords
  375. 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.
  376. #+begin_src emacs-lisp
  377. (use-package password-store
  378. :custom (password-store-dir dotfiles/passwords))
  379. #+end_src
  380. Configure keybindings behind =SPC p=.
  381. + Copy with =p=
  382. + Rename with =r=
  383. + Generate with =g=
  384. #+begin_src emacs-lisp
  385. (dotfiles/leader
  386. "p" '(:ignore t :which-key "Passwords")
  387. "pp" '(password-store-copy :which-key "Copy")
  388. "pr" '(password-store-rename :which-key "Rename")
  389. "pg" '(password-store-generate :which-key "Generate"))
  390. #+end_src
  391. *** Languages
  392. Support for individual languages are implemented here.
  393. **** Go
  394. Install the =gopls= language server.
  395. #+begin_src sh :tangle no
  396. GO111MODULE=on go get golang.org/x/tools/gopls@latest
  397. #+end_src
  398. Set the ~GOPATH~ environment variable prior to loading, this allows us to change the default value of ~$HOME/go~ to ~$HOME/.go~.
  399. #+begin_src emacs-lisp
  400. (setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
  401. #+end_src
  402. Additionally, include the =bin= subdirectory of the ~$GOPATH~ in the ~$PATH~ variable, adding compiled golang programs.
  403. #+begin_src emacs-lisp
  404. (setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
  405. #+end_src
  406. Finally we can include the =go-mode= package, integrating it with =lsp=.
  407. #+begin_src emacs-lisp
  408. (use-package go-mode
  409. :hook (go-mode . lsp)
  410. :custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
  411. #+end_src
  412. Apply some custom behaviour before saving:
  413. + Format buffer
  414. + Organize imports
  415. #+begin_src emacs-lisp
  416. (defun dotfiles/go-hook ()
  417. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  418. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  419. #+end_src
  420. #+begin_src emacs-lisp
  421. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  422. #+end_src
  423. Add a golang source code block structure template with ~<go~:
  424. #+begin_src emacs-lisp
  425. (add-to-list 'org-structure-template-alist '("go" . "src go"))
  426. #+end_src
  427. **** HTTP
  428. Instead of the popular =restclient= package, I use [[https://github.com/zweifisch/ob-http][ob-http]] as a lightweight alternative.
  429. #+begin_src emacs-lisp
  430. (use-package ob-http
  431. :after org
  432. :config (org-babel-do-load-languages
  433. 'org-babel-load-languages
  434. '((http . t))))
  435. #+end_src
  436. **** C/C++
  437. #+ATTR_ORG: :width 420px
  438. #+ATTR_HTML: :width 420px
  439. #+ATTR_LATEX: :width 420px
  440. [[./docs/images/2021-02-13-example-ccls.gif]]
  441. Add support for C/C++ languages.
  442. + Configure the [[https://github.com/MaskRay/ccls][ccls]] language server
  443. + Load babel language modules for C/C++
  444. + Create a new structure templates for C/C++
  445. - ~<cc~ for C
  446. - ~<cpp~ for C++
  447. #+begin_src emacs-lisp
  448. (use-package ccls
  449. :hook ((c-mode c++-mode objc-mode cuda-mode) .
  450. (lambda ()
  451. (require 'ccls)
  452. (lsp-deferred)))
  453. :config (add-to-list 'org-structure-template-alist '("cc" . "src C"))
  454. (add-to-list 'org-structure-template-alist '("cpp" . "src C++"))
  455. (org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
  456. #+end_src
  457. **** Python
  458. Install the =pyls= language server.
  459. #+begin_src shell :tangle no
  460. pip3 install --user "python-language-server[all]"
  461. #+end_src
  462. [[https://www.emacswiki.org/emacs/PythonProgrammingInEmacs][Python-mode]] is an Emacs built in mode.
  463. + Load the babel language module for Python
  464. + Add a python source code block structure template with ~<py~
  465. #+begin_src emacs-lisp
  466. (use-package python-mode
  467. :hook (python-mode . lsp-deferred)
  468. :config (require 'dap-python)
  469. (add-to-list 'org-src-lang-modes '("python" . python))
  470. (add-to-list 'org-structure-template-alist '("py" . "src python"))
  471. (org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
  472. :custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
  473. (dap-python-executable "python3") ;; Same as above.
  474. (dap-python-debugger 'debugpy))
  475. #+end_src
  476. **** PlantUML
  477. Download and install [[https://plantuml.com][PlantUML]], a text-based markup language for creating UML diagrams.
  478. + Load the babel language module for PlantUML
  479. + Create a structure template with ~<pl~
  480. #+begin_src emacs-lisp
  481. (use-package plantuml-mode
  482. :after org
  483. :custom (plantuml-default-exec-mode 'jar)
  484. (plantuml-jar-path "~/.local/bin/plantuml.jar")
  485. (org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
  486. (org-startup-with-inline-images t)
  487. :config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  488. (add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
  489. (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))
  490. #+end_src
  491. Toggle inline images with =SPC t i=.
  492. #+begin_src emacs-lisp
  493. (dotfiles/leader
  494. "ti" '(org-toggle-inline-images :which-key "Images"))
  495. #+end_src
  496. ** Interface
  497. :PROPERTIES:
  498. :header-args: :tangle modules/interface.el
  499. :END:
  500. #+ATTR_ORG: :width 420px
  501. #+ATTR_HTML: :width 420px
  502. #+ATTR_LATEX: :width 420px
  503. [[./docs/images/what-is-emacs-teaser.png]]
  504. *Bring Emacs out of the eighties*
  505. *** Ivy
  506. Download and configure [[https://oremacs.com/swiper/][ivy]], a powerful selection menu for Emacs.
  507. #+begin_src emacs-lisp
  508. (use-package ivy
  509. :diminish
  510. :config (ivy-mode 1))
  511. #+end_src
  512. Counsel is a customized set of commands to replace built in completion buffers.
  513. #+begin_src emacs-lisp
  514. (use-package counsel
  515. :after ivy
  516. :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
  517. :config (counsel-mode 1))
  518. #+end_src
  519. Switch buffers with =SPC , (comma)=.
  520. #+begin_src emacs-lisp
  521. (dotfiles/leader
  522. "," '(counsel-switch-buffer :which-key "Buffers"))
  523. #+end_src
  524. Provide more information about each item with [[https://github.com/Yevgnen/ivy-rich][ivy-rich]].
  525. #+begin_src emacs-lisp
  526. (use-package ivy-rich
  527. :after counsel
  528. :init (ivy-rich-mode 1))
  529. #+end_src
  530. *** Fonts
  531. Write out to all *3* of Emacs' default font faces.
  532. #+begin_src emacs-lisp
  533. (set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size)
  534. (set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size)
  535. (set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size)
  536. #+end_src
  537. Define a transient keybinding for scaling the text.
  538. #+begin_src emacs-lisp
  539. (defhydra hydra-text-scale (:timeout 4)
  540. "Scale"
  541. ("j" text-scale-increase "Increase")
  542. ("k" text-scale-decrease "Decrease")
  543. ("f" nil "Finished" :exit t))
  544. #+end_src
  545. Increase the font size in buffers with =SPC t f=.
  546. + Increase =j=
  547. + Decrease =k=
  548. + Finish =f=
  549. #+begin_src emacs-lisp
  550. (dotfiles/leader
  551. "tf" '(hydra-text-scale/body :which-key "Font"))
  552. #+end_src
  553. *** Lines
  554. 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.
  555. #+begin_example
  556. 5:
  557. 4:
  558. 3:
  559. 2:
  560. 1:
  561. 156: << CURRENT LINE >>
  562. 1:
  563. 2:
  564. 3:
  565. 4:
  566. 5:
  567. #+end_example
  568. https://github.com/emacsmirror/linum-relative
  569. + Integrate with ~display-line-numbers-mode~ for performance
  570. #+begin_src emacs-lisp
  571. (use-package linum-relative
  572. :commands (linum-relative-global-mode)
  573. :custom (linum-relative-backend 'display-line-numbers-mode))
  574. #+end_src
  575. Add line numbers to the toggles behind =SPC t l=.
  576. #+begin_src emacs-lisp
  577. (dotfiles/leader
  578. "tl" '(linum-relative-global-mode :which-key "Lines"))
  579. #+end_src
  580. https://github.com/Fanael/rainbow-delimiters
  581. + Colourize nested parenthesis
  582. #+begin_src emacs-lisp
  583. (use-package rainbow-delimiters
  584. :hook (prog-mode . rainbow-delimiters-mode))
  585. #+end_src
  586. *** Themes
  587. #+ATTR_ORG: :width 420px
  588. #+ATTR_HTML: :width 420px
  589. #+ATTR_LATEX: :width 420px
  590. [[./docs/images/what-is-emacs-customizable.gif]]
  591. 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.
  592. #+begin_src emacs-lisp
  593. (use-package doom-themes
  594. :init (load-theme 'doom-moonlight t))
  595. #+end_src
  596. [[https://github.com/seagle0128/doom-modeline][doom-modeline]] provides an elegant status bar / modeline.
  597. #+begin_src emacs-lisp
  598. (use-package doom-modeline
  599. :custom (doom-modeline-height 16)
  600. :config (doom-modeline-mode 1))
  601. #+end_src
  602. Load a theme with =SPC t t=.
  603. #+begin_src emacs-lisp
  604. (dotfiles/leader
  605. "tt" '(counsel-load-theme t t :which-key "Theme"))
  606. #+end_src
  607. *** Pretty
  608. Make programming buffers prettier with [[https://github.com/pretty-mode/pretty-mode][pretty-mode]], complimentary to the built in ~prettify-symbols-mode~.
  609. #+begin_src emacs-lisp
  610. (use-package pretty-mode
  611. :hook (python-mode . turn-on-pretty-mode))
  612. #+end_src
  613. *** Ligatures
  614. Enable font ligatures via [[https://github.com/jming422/fira-code-mode][fira-code-mode]], perform this action *only* when ~Fira Code~ is the current font.
  615. #+begin_src emacs-lisp
  616. (when (display-graphic-p)
  617. (use-package fira-code-mode
  618. :hook (prog-mode org-mode)))
  619. #+end_src
  620. Toggle global ligature mode with =SPC t g=.
  621. #+begin_src emacs-lisp
  622. (dotfiles/leader
  623. "tg" '(global-fira-code-mode :which-key "Ligatures"))
  624. #+end_src
  625. *** Dashboard
  626. #+ATTR_ORG: :width 420px
  627. #+ATTR_HTML: :width 420px
  628. #+ATTR_LATEX: :width 420px
  629. [[./docs/images/desktop.png]]
  630. Present a dashboard when first launching Emacs. Customize the buttons of the navigator:
  631. + Brain @ http://localhost:8080
  632. + Homepage @ https://chrishayward.xyz
  633. + Athabasca @ https://login.athabascau.ca/cas/login
  634. + Bookshelf @ https://online.vitalsource.com
  635. #+begin_src emacs-lisp
  636. (use-package dashboard
  637. :custom (dashboard-center-content t)
  638. (dashboard-set-init-info t)
  639. (dashboard-set-file-icons t)
  640. (dashboard-set-heading-icons t)
  641. (dashboard-set-navigator t)
  642. (dashboard-startup-banner 'logo)
  643. (dashboard-projects-backend 'projectile)
  644. (dashboard-items '((projects . 5) (recents . 5) (agenda . 10)))
  645. (dashboard-navigator-buttons `(((,(all-the-icons-fileicon "brain" :height 1.1 :v-adjust 0.0)
  646. "Brain" "Knowledge base"
  647. (lambda (&rest _) (browse-url "http://localhost:8080"))))
  648. ((,(all-the-icons-material "public" :height 1.1 :v-adjust 0.0)
  649. "Homepage" "Personal website"
  650. (lambda (&rest _) (browse-url "https://chrishayward.xyz"))))
  651. ((,(all-the-icons-faicon "university" :height 1.1 :v-adjust 0.0)
  652. "Athabasca" "Univeristy login"
  653. (lambda (&rest _) (browse-url "https://login.athabascau.ca/cas/login"))))
  654. ((,(all-the-icons-faicon "book" :height 1.1 :v-adjust 0.0)
  655. "Bookshelf" "Vitalsource bookshelf"
  656. (lambda (&rest _) (browse-url "https://online.vitalsource.com"))))))
  657. :config (dashboard-setup-startup-hook))
  658. #+end_src
  659. When running in *daemon* mode, ensure that the dashboard is the initial buffer.
  660. #+begin_src emacs-lisp
  661. (setq initial-buffer-choice
  662. (lambda ()
  663. (get-buffer "*dashboard*")))
  664. #+end_src