Tinymist Docs

Tinymist Emacs Support for Typst

Run and configure tinymist in Emacs for Typst.

Features

See Tinymist Features for a list of features.

Finding Executable

To enable LSP, you must install tinymisttinymist. You can find tinymisttinymist by:

  • Night versions available at GitHub Actions.

  • Stable versions available at GitHub Releases.
    If you are using the latest version of typst-ts-mode, then you can use command typst-ts-lsp-download-binarytypst-ts-lsp-download-binary to download the latest stable binary of tinymisttinymist at typst-ts-lsp-download-pathtypst-ts-lsp-download-path.

  • Build from source by cargo. You can also compile and install latest tinymisttinymist by Cargo.

    
                                        
    cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked tinymist-cli
    
                                        
    cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked tinymist-cli
    
                                        
    cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked tinymist-cli
    
                                        
    cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked tinymist-cli

Setup Server


                                
(with-eval-after-load 'eglot

                                
  (with-eval-after-load 'typst-ts-mode

                                
    (add-to-list 'eglot-server-programs

                                
                 `((typst-ts-mode) .

                                
                   ,(eglot-alternatives `(,typst-ts-lsp-download-path

                                
                                          "tinymist"

                                
                                          "typst-lsp"))))))

                                
(with-eval-after-load 'eglot

                                
  (with-eval-after-load 'typst-ts-mode

                                
    (add-to-list 'eglot-server-programs

                                
                 `((typst-ts-mode) .

                                
                   ,(eglot-alternatives `(,typst-ts-lsp-download-path

                                
                                          "tinymist"

                                
                                          "typst-lsp"))))))

                                
(with-eval-after-load 'eglot

                                
  (with-eval-after-load 'typst-ts-mode

                                
    (add-to-list 'eglot-server-programs

                                
                 `((typst-ts-mode) .

                                
                   ,(eglot-alternatives `(,typst-ts-lsp-download-path

                                
                                          "tinymist"

                                
                                          "typst-lsp"))))))

                                
(with-eval-after-load 'eglot

                                
  (with-eval-after-load 'typst-ts-mode

                                
    (add-to-list 'eglot-server-programs

                                
                 `((typst-ts-mode) .

                                
                   ,(eglot-alternatives `(,typst-ts-lsp-download-path

                                
                                          "tinymist"

                                
                                          "typst-lsp"))))))

Above code adds tinymisttinymist downloaded by typst-ts-lsp-download-binarytypst-ts-lsp-download-binary, tinymisttinymist in your PATH and typst-lsptypst-lsp in your PATHPATH to the typst-ts-modetypst-ts-mode entry of eglot-server-programseglot-server-programs.

Extra Settings

Configuring Language Server

You can either use eglot-workspace-configurationeglot-workspace-configuration or specifying launch arguments for tinymisttinymist.

Working under Power-Saving Mode or with Resource-consumed Projects

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 setting the tinymist.syntaxOnlytinymist.syntaxOnly to enableenable or onPowerSavingonPowerSaving in the configuration.

For more information about power-saving mode, see Syntax-Only Mode.

eglot-workspace-configuration

For example, if you want to export PDF on save:


                                
  (setq-default eglot-workspace-configuration

                                
                '(:tinymist (:exportPdf "onSave")))

                                
  (setq-default eglot-workspace-configuration

                                
                '(:tinymist (:exportPdf "onSave")))

                                
  (setq-default eglot-workspace-configuration

                                
                '(:tinymist (:exportPdf "onSave")))

                                
  (setq-default eglot-workspace-configuration

                                
                '(:tinymist (:exportPdf "onSave")))

You can also have configuration per directory. Be sure to look at the documentation of eglot-workspace-configurationeglot-workspace-configuration by describe-symboldescribe-symbol..

See Tinymist Server Configuration for references.

Launch Arguments

For example:


                                
(with-eval-after-load 'eglot

                                
  (with-eval-after-load 'typst-ts-mode

                                
    (add-to-list 'eglot-server-programs

                                
                 `((typst-ts-mode) .

                                
                   ,(eglot-alternatives `((,typst-ts-lsp-download-path "--font-path" "<your-font-path>")

                                
                                          ("tinymist" "--font-path" "<your-font-path>")

                                
                                          "typst-lsp"))))))

                                
(with-eval-after-load 'eglot

                                
  (with-eval-after-load 'typst-ts-mode

                                
    (add-to-list 'eglot-server-programs

                                
                 `((typst-ts-mode) .

                                
                   ,(eglot-alternatives `((,typst-ts-lsp-download-path "--font-path" "<your-font-path>")

                                
                                          ("tinymist" "--font-path" "<your-font-path>")

                                
                                          "typst-lsp"))))))

                                
(with-eval-after-load 'eglot

                                
  (with-eval-after-load 'typst-ts-mode

                                
    (add-to-list 'eglot-server-programs

                                
                 `((typst-ts-mode) .

                                
                   ,(eglot-alternatives `((,typst-ts-lsp-download-path "--font-path" "<your-font-path>")

                                
                                          ("tinymist" "--font-path" "<your-font-path>")

                                
                                          "typst-lsp"))))))

                                
(with-eval-after-load 'eglot

                                
  (with-eval-after-load 'typst-ts-mode

                                
    (add-to-list 'eglot-server-programs

                                
                 `((typst-ts-mode) .

                                
                   ,(eglot-alternatives `((,typst-ts-lsp-download-path "--font-path" "<your-font-path>")

                                
                                          ("tinymist" "--font-path" "<your-font-path>")

                                
                                          "typst-lsp"))))))

You can run command tinymist help lsptinymist help lsp to view all available launch arguments for configuration.