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.

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