Tinymist Typst VS Code Extension
A VS Code or VS Codium extension for Typst. You can find the extension on:
- Stable and pre-release versions available at Visual Studio Marketplace and Open VSX.
- The artifacts built per commits at GitHub Actions.
- The artifacts built per release at GitHub Releases.
See Tinymist Features for a list of features.
The Software Specification contains user interface provided by this extension, You could find solutions by text search in the docs or ask LLMs with plugging the docs.
To initialize a Typst project:
- Use command
Typst init templateTypst init template(tinymist.initTemplate) to initialize a new Typst project based on a template. - Use command
Typst show templateTypst show template(tinymist.showTemplateGallery) to show available Typst templates for picking up a template to initialize.
🎉 If your template contains only a single file, you can also insert the template content in place with command:
- Use command
Typst template in placeTypst template in place(tinymist.initTemplateInPlace) and input a template specifier for initialization.
- Open settings.
-
Search for "Tinymist Formatter" and modify the value.
Tips: to enable formatting on save, you should add extra settings for typst language:
- Open settings.
-
Search for "Tinymist Lint" and modify the value.
- Toggle "Enabled" to enable or disable the linter.
-
Change "When" to configure when the linter runs.
- (Default)
onSaveonSaverun linting when you save the file. onTypeonTyperun linting as you type.
- (Default)
If you don’t like the activity bar, you can right-click on the activity bar and uncheck "Tinymist" to hide it.
- Search symbols by keywords, descriptions, or handwriting.
- See symbols grouped by categories.
- Click on a symbol, then it will be inserted into the editor.
- Template Gallery: Show available Typst templates for picking up a template to initialize.
- Document Summary: Show a summary of the current document.
- Symbols: Show symbols in the current document.
- Fonts: Show fonts in the current document.
- Profiling: Profile the current document.
- Create or open some local typst packages.
- Show a list of available typst packages and invoke associated commands.
- Show thumbnail content of the current document, which is useful for creating slides.
- Show labels in the current workspace.
-
Show outline of exported document, viewing typst as a markup language.
- This is slightly different from the LSP-provided document outline, which shows the syntax structure of the document, viewing typst as a programming language.
Open command palette (Ctrl+Shift+P), and type >Typst Preview:>Typst Preview:.
You can also use the shortcut (Ctrl+K V).
In short, there is a sys.inputssys.inputs item added to the compiler when your document is under the context of user editing or previewing task. You can use it to configure your template:
For details, please check Preview’s sys.inputs.
To configure path to search fonts:
-
Open settings.
- File -> Preferences -> Settings (Linux, Windows).
- Code -> Preferences -> Settings (Mac).
- Search for "Tinymist Font Paths" for providing paths to search fonts order-by-order.
- Search for "Tinymist System Fonts" for disabling system fonts to be searched, which is useful for reproducible rendering your PDF documents.
- Reload the window or restart the vscode editor to make the settings take effect.
Note: you must provide absolute paths.
Note: you can use vscode variables in the settings, see vscode-variables for more information.
To configure the root path resolved for Typst compiler:
- Open settings.
- Search for "Tinymist Root Path" and modify the value.
- Reload the window or restart the vscode editor to make the settings take effect. Note: you must provide absolute paths.
- Use
Typst: Create Typst Local PackageTypst: Create Typst Local Packagecommand to create a local package. - Use
Typst: Open Typst Local PackageTypst: Open Typst Local Packagecommand to open a local package. - View and manage a list of available local packages in the "PACKAGE" view in the activity bar.
This extension compiles to PDF, but it doesn’t have a PDF viewer yet. To view the output as you work, install a PDF viewer extension, such as vscode-pdfvscode-pdf.
To find a way to compile PDF:
- Click the code len
Export PDFExport PDFat the top of document, or use commandTypst Show PDF ...Typst Show PDF ..., to show the current document to PDF. - Use command
Typst Export PDFTypst Export PDFto export the current document to PDF. - There are code lens buttons at the start of the document to export your document to PDF or other formats.
To configure when PDFs are compiled:
- Open settings.
- Search for "Tinymist Export PDF".
-
Change the "Export PDF" setting.
onSaveonSavemakes a PDF after saving the Typst file.onTypeonTypemakes PDF files live, as you type.neverneverdisables PDF compilation.onDocumentHasTitleonDocumentHasTitlemakes a PDF when the document has a title and, as you save.
To configure where PDFs are saved:
- Open settings.
- Search for "Tinymist Output Path".
-
Change the "Output Path" setting. This is the path pattern to store artifacts, you can use
$root$rootor$dir$diror$name$nameto do magic configuration- e.g.
$root/$dir/$name$root/$dir/$name(default) for$root/path/to/main.pdf$root/path/to/main.pdf. - e.g.
$root/target/$dir/$name$root/target/$dir/$namefor$root/target/path/to/main.pdf$root/target/path/to/main.pdf. - e.g.
$root/target/foo$root/target/foofor$root/target/foo.pdf$root/target/foo.pdf. This will ensure that the output is always output totarget/foo.pdftarget/foo.pdf.
- e.g.
Note: the output path should be substituted as an absolute path.
You can export your documents to various other formats by lsp as well. Currently, the following formats are supported:
- Official svg, png, and pdf.
- Unofficial html, md (typlite), and txt
- Query Results (into json, yaml, or txt), and pdfpc (by
typst query --selector <pdfpc-file>typst query --selector <pdfpc-file>, for Touying)
See Docs: Exporting Documents for more information.
When working under power-saving mode or with resource-consumed projects, typst compilations costs too much CPU and memory resources. You can configure the extension to run in syntax only mode, i.e. only performing elementary tasks, like syntax checking, syntax-only code analysis and formatting, by:
- Open settings.
- Search for "Tinymist Syntax Only Mode".
- Toggle the "Syntax Only Mode" setting to always enable, disable syntax only mode, or enable on power-saving mode.
For more information about power-saving mode, see Syntax-Only Mode.
You can pin a main file by command.
- Use command
Typst Pin MainTypst Pin Main(tinymist.pinMainToCurrent) to set the current file as the main file. - Use command
Typst Unpin MainTypst Unpin Main(tinymist.unpinMain) to unset the main file.
tinymist.pinMaintinymist.pinMain is a stateful command, and tinymist doesn't remember it between sessions (closing and opening the editor).There is a global configuration tinymist.typstExtraArgstinymist.typstExtraArgs to pass extra arguments to tinymist LSP, like what you usually do with typst-clitypst-cli CLI. For example, you can set it to ["--input=awa=1", "--input=abaaba=2", "main.typ"]["--input=awa=1", "--input=abaaba=2", "main.typ"] to configure sys.inputssys.inputs and entry for compiler, which is equivalent to make LSP run like a typst-clitypst-cli with such arguments:
Supported arguments:
-
entry file: The last string in the array will be treated as the entry file.
- This is used to specify the default entry file for the compiler, which may be overridden by other settings.
--input--input: Add a string key-value pair visible throughsys.inputssys.inputs.--font-path--font-path(environment variable:TYPST_FONT_PATHSTYPST_FONT_PATHS), Font paths, maybe overridden bytinymist.fontPathstinymist.fontPaths.--ignore-system-fonts--ignore-system-fonts: Ensures system fonts won’t be searched, maybe overridden bytinymist.systemFontstinymist.systemFonts.--creation-timestamp--creation-timestamp(environment variable:SOURCE_DATE_EPOCHSOURCE_DATE_EPOCH): The document’s creation date formatted as a UNIX timestamp.--cert--cert(environment variable:TYPST_CERTTYPST_CERT): Path to CA certificate file for network access, especially for downloading typst packages.
Note: Fix entry to main.typmain.typ may help multiple-file projects but you may loss diagnostics and autocompletions in unrelated files.
Note: the arguments has quite low priority, and that may be overridden by other settings.
You can submit issues or make PRs to GitHub.