Preview Feature
Two ways of previewing a Typst document are provided:
- PDF Preview: let lsp export your PDF on typed, and open related PDF by your favorite PDF viewer.
- Web (SVG) Preview: use builtin preview feature.
Whenever you can get a web preview feature, it is recommended since it is much faster than PDF preview and provides bidirectional navigation feature, allowing jumping between the source code and the preview by clicking or lsp commands.
For non-vscode clients, Neovim client as an example. One who uses nvim-lspconfig
nvim-lspconfig
can place their configuration in the servers.tinymist.settings
servers.tinymist.settings
section. If you want to export PDF on typing and output files in $root_dir/target
$root_dir/target
directory, please configure it like that:
The corresponding configuration should be placed in the settings.json
settings.json
file. For example:
Also see:
You can use tinymist.startDefaultPreview
tinymist.startDefaultPreview
command to start a preview instance without arguments. This is used for the case where a client cannot pass arguments to the preview command, e.g. helix. Default Behaviors:
- The preview server listens on a random port.
- The colors are inverted according to the browser (usually also system) settings.
- The preview follows an inferred focused file from the requests from the client.
- The preview is opened in the default browser.
You can set the arguments to used by configuration tinymist.preview.browsing.args
tinymist.preview.browsing.args
to override the default behavior. The default value is ["--data-plane-host=127.0.0.1:0", "--invert-colors=auto", "--open"]
["--data-plane-host=127.0.0.1:0", "--invert-colors=auto", "--open"]
. Intentionally, the name of the configuration is not tinymist.defaultPreviewArgs
tinymist.defaultPreviewArgs
or tinymist.preview.defaultArgs
tinymist.preview.defaultArgs
to avoid confusion.
You can start a preview instance in background with configuration:
Default Behaviors:
- The preview server listens on
127.0.0.1:23635
127.0.0.1:23635
. - The colors are inverted according to the browser (usually also system) settings.
- The preview follows an inferred focused file from the requests from the client.
You can set the arguments to used by configuration tinymist.preview.background.args
tinymist.preview.background.args
to override the default behavior. The default value is ["--data-plane-host=127.0.0.1:23635", "--invert-colors=auto"]
["--data-plane-host=127.0.0.1:23635", "--invert-colors=auto"]
. Example:
is equivalent to
You may seek typst-preview.nvim for the preview feature.
You may seek typst-preview.el for the preview feature.
If the document is compiled by lsp, you can use sys.inputs
sys.inputs
to get the preview arguments:
There is a version
version
field in the preview-args
preview-args
object, which will increase when the scheme of the preview arguments is changed.
See Typst-Preview Developer Guide.
The only two abstracted theme kinds are supported: light
light
and dark
dark
. You can use the following code to get the theme: