This is a short note on setting up Doom emacs for very fast typst previews.
typst-ts-mode provides typst-ts-watch-mode via C-c C-w, which runs typst watch in the background, as well as typst-ts-preview via C-c C-p which
opens the current pdf file. Using zathura as pdf viewer provides live updates.
| |
Since typst is so fast to compile, and near-live previews are nice, we’d like to
save the file often. Since space f s is somewhat annoying to type all the
time, we’ll add some auto-saving.
As suggested by jrmoulton in the comments, tinymist (gh) is an LSP that provides actual live-previews.
We save when emacs loses focus using
| |
Even better, I have caps-lock mapped to escape, so I remapped escape in normal mode to save as well:
| |
It does not work super smoothly because it seems to inhibit some other things that run on escape, but it’s good enough for now1 and I use it a lot.
Another thing I tried before that is save on exiting insert mode, but this
turned out not as useful as I thought: sometimes it’s annoying to auto-format-on-save
the buffer while you’re making changes, and there are changes like deleting a
line with dd that never enter insert mode, and so manual saving would still be
necessary in that case anyway. But anyway, I had the following snippet for that:
| |
Note that I’m a complete elisp noob. Feel free to suggest improvements. ↩︎