Published

- 4 min read

Emacs, Doom and Despair

img of Emacs, Doom and Despair

Background

My experience with confusing editors and tools like vim and emacs started back when I was on valkyrie robotics. The entire software division (or at least the tryhards) all used doom emacs, with their individualized configs and minimalist themes (though I would later learn all of their configs were copied from one particularly influential alumnus). I felt a bit out of place, and I asked the software mentor which editor I should learn. He personally used spacemacs, but (thankfully) recognized my naivete (incompetence) and suggested I simply use vs code with the vim extension. I remember the first time I tried using vim keybinds and how nothing seemed to work. I fumbled around with guides online, but by the end of the week I had given up and turned off the extension. It’s evident that my programming and general CS skills have increased immensely since my days on wyrd, so I’m taking another shot at doom emacs. I feel a bit as though I’ve come back to slay the boss I could never get past as a kid, and I’m confident in my abilities to learn doom emacs this time.

Setting up Emacs

Setting up emacs to make it even semi-usable has been a difficult struggle. Last time I installed it was on my windows computer, so I was starting this journey from scratch. I initially used the emacs-mac port as recommended by doom, but that doesn’t support emacs 30 and I need astro-ts-theme which only works on emacs 30+. So I had to remove emacs-mac and switch to emacs-plus. This also solved another issue I was facing, which was running the emacs daemon and creating clients for faster startup. For some reason, this didn’t work with emacs-mac. My config is still quite small and its easy to keep it organized, but in the future I’ll consider writing my own module for my config if it gets too large and unruly.

Languages

Configuring emacs to run with astro and c++ wasn’t to difficult due to some online guides I found, but treesitter (treesit? idk the difference) was such a pain due to some obscure issues with the auto install list for language grammers. Here’s what I ended up with after copying some guides and fixing some issues I ran into:

   (use-package! treesit-auto
  :custom
  (treesit-auto-install 'prompt)
  :config
  (treesit-auto-add-to-auto-mode-alist 'all)
  (global-treesit-auto-mode))

(use-package! astro-ts-mode
  :config
  (let ((astro-recipe (make-treesit-auto-recipe
                       :lang 'astro
                       :ts-mode 'astro-ts-mode
                       :url "https://github.com/virchau13/tree-sitter-astro"
                       :revision "master"
                       :source-dir "src")))
    (add-to-list 'treesit-auto-recipe-list astro-recipe)
    (add-to-list 'treesit-auto-langs 'astro))
  )

(set-formatter! 'prettier-astro
  '("npx" "prettier" "--parser=astro"
    (apheleia-formatters-indent "--use-tabs" "--tab-width" 'astro-ts-mode-indent-offset))
  :modes '(astro-ts-mode))

(use-package! lsp-tailwindcss
  :init
  (setq! lsp-tailwindcss-add-on-mode t)
  :config
  (add-to-list 'lsp-tailwindcss-major-modes 'astro-ts-mode))

;; MDX Support
(add-to-list 'auto-mode-alist '("\\.\\(mdx\\)$" . markdown-mode))
(add-hook 'markdown-mode-local-vars-hook #'lsp! 'append)

Github

Setting up github on doom emacs was much harder than it needed to be. I went down a rabbit hole of .authinfo.gpg and authentication tokens but in the end the issue was that git was not even configured at all on my mac. Installing github CLI and following their authentication procedures is enough since they store it for me. Magit seems to be quite helpful with the different functions of git, but I’m not really using it to its fullest potential as the only git commands I use are usable from the command line anyways (push, pull, add). I’m never really dealing with merge conflicts or looking through commits in my editor, but I suspect I will in the future so its good that I’m familiarizing myself with the tool.

Using Emacs

Messing around with my config is my unconscious mind secretly putting off the real challenge: learning keybinds and unlocking emacs’s true potential. I’ve been getting the hang of general window navigation keybinds, but I still have issues with code editing keybinds. It doesn’t help that I don’t even know which keybinds are evil and which are normal, so I might just be learning the wrong commands for things that could be a lot easier. I appreciate the fact that it shows a list of commands when you start typing it out, so I just need to remember that Spc w opens window related keybinds, Spc f opens file related keybinds, and other prefixes of commands. My productivity hasn’t improved noticeably, but I have been learning a lot about general computer knowledge through this process of configuring and using emacs. One thing I am wary about is that my general typing speed isn’t notably fast, and I’m not sure if its hindering progress learning emacs keybinds and using the keyboard instead of a mouse. I’ll do my best to update my progress on learning these keybinds as I go.