I do all my Typst editing in Helix with Tinymist and it works well for me. For preview with Tinymist you have a choice:
-
Preview in PDF. Depending on settings the PDF gets recompiled either when you save (basically the same as
typst watch) or on each keystroke. It’s the simplest to configure, but even with preview on keystroke there’s quite some lag and as far as I know there’s no way to get synctex-like “click PDF to jump to source code”.To export PDF when you save the source file you can use the following in the Helix
languages.toml:[language-server.tinymist] command = "tinymist" config.exportPdf = "onSave"Replace
onSavewithonTypeto export on each keystroke. -
Live preview in browser. In this case Tinymist serves a web page locally on some port. When you load this page in the browser you see the document, and changes are applied instantly (much snappier than with PDF export.) And it supports click-to-source!
The live preview configuration is documented here and here but it’s a bit messy currently. Here’s what I use:
[language-server.tinymist] command = "tinymist" config.preview.background.enabled = true config.preview.background.args = [ "--data-plane-host=127.0.0.1:0", "--invert-colors=never", "--open"]This specifies
0for the server port, so Tinymist will choose a random port the first time I open a Typst file in a given Helix instance. With--open, Tinymist will also open a tab in my browser showing the page served on this port. So with this configuration I automatically get one preview tab in the browser for each Helix instance that edits Typst files.
The next big issue is how to handle multi-file projects. Here also you have the choice:
-
Hardcode the main file in each project’s directory. In the directory you create a local config file
.helix/languages.tomlwith something like[language-server.tinymist.config] typstExtraArgs = ["my-main-file.typ"]I find it a bit annoying to maintain these config files, especially when I want to switch between different “main” files in the same directory.
-
Configure a keybinding to pin the current file as “main”. With the latest Helix version (25.07) it is now possible to send commands with arguments to the Language Server (Tinymist), so you can add the following to the Helix config file (
~/.config/helix/config.tomlon Linux):[keys.normal] "C-p" = ':lsp-workspace-command tinymist.pinMain "%sh{realpath %{buffer_name}}"'This way you can press
Ctrl+Pin Helix in normal mode to pin the current file as “main” for the browser preview. In the same Helix instance you can switch to e.g.main2.typ, pressCtrl+Pagain and the same browser tab will now show the preview usingmain2.typas main file.
(Edit: replaced Ctrl-M keybinding with Ctrl-P since Ctrl-M is not usable in all terminals.)