coc-tinymist
v0.2.0
Published
Typst language support for coc.nvim powered by Tinymist
Readme
coc-tinymist
Typst language support for coc.nvim, powered by Tinymist.
Install
:CocInstall coc-tinymistThen open a .typ file. If no Tinymist executable is configured, coc-tinymist can download a managed Tinymist release on first use.
Server Setup
coc-tinymist resolves the server in this order:
tinymist.serverPath- the extension-managed Tinymist binary
tinymistfrom$PATH
The default update mode is prompt: the extension asks before installing a missing managed server or updating an existing one. Use manual, auto, or never if you want tighter control.
{
"tinymist.updates.mode": "prompt"
}Useful server commands:
:CocCommand tinymist.install
:CocCommand tinymist.update
:CocCommand tinymist.useManagedServer
:CocCommand tinymist.useSystemServer
:CocCommand tinymist.useCustomServer
:CocCommand tinymist.restartServer
:CocCommand tinymist.serverVersionIf you already have a manual languageserver.tinymist entry in coc-settings.json, remove it or run:
:CocCommand tinymist.checkDuplicateServerConfiguration
Put settings in :CocConfig or a workspace .vim/coc-settings.json.
{
"tinymist.enable": true,
"tinymist.updates.mode": "prompt",
"tinymist.serverPath": null,
"tinymist.serverArgs": ["lsp"],
"tinymist.formatterMode": "typstyle",
"tinymist.formatterPrintWidth": 120,
"tinymist.exportOnSave": [],
"tinymist.exportOutputDirectory": null,
"tinymist.compileStatus": "disable",
"tinymist.statusBarFormat": "{compileStatusIcon} {wordCount} [{fileName}]"
}All configuration keys are contributed to Coc's JSON schema and grouped below.
Server
| Setting | Default | Description |
| --- | --- | --- |
| tinymist.enable | true | Enable coc-tinymist. |
| tinymist.serverPath | null | Absolute path to a Tinymist executable. When unset, coc-tinymist uses a managed binary or $PATH. |
| tinymist.serverArgs | ["lsp"] | Arguments passed to Tinymist. |
| tinymist.serverExtraEnv | null | Extra environment variables for Tinymist. |
| tinymist.restartServerOnConfigChange | false | Restart Tinymist when process-level settings change. |
| tinymist.trace.server | "off" | Trace LSP traffic: off, messages, or verbose. |
| tinymist.customizedShowDocument | true | Use Tinymist custom source-jump notifications for browser preview inverse sync. |
| tinymist.updates.mode | "prompt" | Managed server install/update mode: prompt, auto, manual, or never. |
| tinymist.updates.checkOnStartup | true | Check managed server updates on startup. |
| tinymist.updates.prompt | true | Deprecated. Use tinymist.updates.mode instead. |
Project and Compiler
| Setting | Default | Description |
| --- | --- | --- |
| tinymist.projectResolution | "singleFile" | Use the focused file as the project entry or Tinymist's lock database. |
| tinymist.syntaxOnly | "auto" | Control Tinymist syntax-only mode. |
| tinymist.rootPath | null | Root path for Typst compilation. |
| tinymist.outputPath | "" | Tinymist output path pattern. |
| tinymist.exportTarget | "paged" | Default Tinymist export target: paged, html, or bundle. |
| tinymist.typstExtraArgs | [] | Extra Typst CLI-shaped arguments parsed by Tinymist. |
| tinymist.systemFonts | true | Load system fonts in Tinymist's shared compiler environment. |
| tinymist.fontPaths | null | Font files or directories for Tinymist. |
Formatting and Language Features
| Setting | Default | Description |
| --- | --- | --- |
| tinymist.formatterMode | "typstyle" | Formatter backend: disable, typstyle, or typstfmt. |
| tinymist.formatterPrintWidth | 120 | Soft print-width limit. |
| tinymist.formatterIndentSize | 2 | Formatter indent size. |
| tinymist.formatterProseWrap | false | Hard-wrap prose at the configured print width. |
| tinymist.semanticTokens | "enable" | Enable Tinymist semantic token data. Coc highlighting still requires semanticTokens.enable. |
| tinymist.inlayHints.packageVersionStatus | true | Show package version status hints when Coc inlay hints are enabled. |
| tinymist.cocFallbackDocumentHighlight | true | Use Coc-side exact-match highlights only when Tinymist returns no highlights. |
| tinymist.cocFallbackInlayHints | false | Add simple Coc-side Typst function parameter hints. |
| tinymist.fallback.maxFileBytes | 524288 | Maximum document size for Coc-side fallback parsing. |
| tinymist.fallback.maxHighlights | 500 | Maximum fallback document highlights per request. |
| tinymist.fallback.maxInlayHints | 500 | Maximum fallback inlay hints per request. |
| tinymist.onEnterEvent | false | Enable Coc-side Enter handling through Tinymist experimental/onEnter. |
| tinymist.typingContinueCommentsOnNewline | true | Continue Typst comments when Coc-side Enter handling is enabled. |
| tinymist.lint.enabled | false | Enable Tinymist lint diagnostics. |
| tinymist.lint.when | "onSave" | Run linting on save or typing. |
Export, Tasks, and Status
| Setting | Default | Description |
| --- | --- | --- |
| tinymist.exportOnSave | [] | Extension-side automatic exports after save. Use true, "Pdf", or an array like ["Pdf", "Html"]. |
| tinymist.exportOnType | [] | Extension-side automatic exports after typing changes. |
| tinymist.exportOnIdle | [] | Extension-side automatic exports after the document is idle. |
| tinymist.exportPdf | "never" | Tinymist server-side PDF export trigger: never, onSave, onType, or onDocumentHasTitle. |
| tinymist.exportOutputDirectory | null | Directory for automatic export artifacts. |
| tinymist.exportOpenAfterSave | false | Open the first save-triggered export artifact. |
| tinymist.exportShowIn | "message" | Show automatic export results in none, message, output, quickfix, or open. |
| tinymist.preview.refresh | "onType" | Browser preview refresh mode: onType or onSave. |
| tinymist.preview.partialRendering | true | Use Tinymist preview partial rendering when supported. |
| tinymist.preview.invertColors | "never" | Browser preview color inversion: never, auto, always, or an object for rest/image. |
| tinymist.preview.scrollSync | "never" | Automatically scroll browser preview from the source cursor. Use onSelectionChange to sync cursor movement. |
| tinymist.preview.cursorIndicator | false | Send source cursor indicator updates to the browser preview. |
| tinymist.mainFile.store | "workspaceState" | Persist pinned main files per workspace, or use none for memory-only pinning. |
| tinymist.tasks.workspaceFileLimit | 100 | Maximum .typ files for workspace tests. |
| tinymist.tasks.workspaceTimeoutMs | 120000 | Workspace task timeout. |
| tinymist.tasks.fileTimeoutMs | 30000 | Per-file task timeout. |
| tinymist.tasks.maxOutputBytes | 1048576 | Captured stdout/stderr limit per stream. |
| tinymist.tasks.progressIntervalMs | 2000 | Minimum interval between workspace task progress updates. |
| tinymist.commands.exportTimeoutMs | 120000 | Timeout for Tinymist export execute-command requests. |
| tinymist.commands.profileTimeoutMs | 120000 | Timeout for Tinymist profile execute-command requests. |
| tinymist.commands.templateTimeoutMs | 60000 | Timeout for Tinymist template execute-command requests. |
| tinymist.commands.previewTimeoutMs | 120000 | Timeout for Tinymist preview execute-command requests. |
| tinymist.compileStatus | "disable" | Enable compile status notifications and the status item. |
| tinymist.statusBarFormat | "{compileStatusIcon} {wordCount} [{fileName}]" | Status item format. Set to "" to hide the item while keeping notifications. |
tinymist.exportTo lets you choose a format and destination. Output paths can use {name}, {ext}, {kind}, {index}, {page}, {hash}, and {relativeDir} placeholders:
{
"tinymist.outputPath": "build/{relativeDir}/{name}-{page}.{ext}"
}If a multi-file export targets slides.png, coc-tinymist writes slides.png, slides-2.png, slides-3.png, and so on.
Markdown Trust
| Setting | Default | Description |
| --- | --- | --- |
| tinymist.markdown.isTrusted | false | Trust Markdown returned by Tinymist. Enable only if you want command links in server-provided Markdown to run. |
| tinymist.markdown.supportHtml | false | Render raw HTML in Tinymist Markdown. Enable only for trusted projects and packages. |
Commands
Run commands with :CocCommand.
Server and Config
| Command | Description |
| --- | --- |
| tinymist.actions | Pick from grouped Tinymist actions. |
| tinymist.restartServer | Restart the Tinymist language server. |
| tinymist.install | Install Tinymist from GitHub releases. |
| tinymist.update | Check for and install a managed Tinymist update. |
| tinymist.serverVersion | Show the active Tinymist version and source. |
| tinymist.showStatus | Show the latest Tinymist status details. |
| tinymist.showLog | Open the Tinymist language server log. |
| tinymist.doctor | Open a diagnostic report for server, config, workspace, and status. |
| tinymist.doctorCopyIssueTemplate | Copy a sanitized issue report to the clipboard. |
| tinymist.doctorSaveReport | Save a sanitized doctor report to a temp file. |
| tinymist.checkDuplicateServer | Check for a duplicate manual languageserver.tinymist config. |
| tinymist.openConfig | Open user coc-settings.json. |
| tinymist.openWorkspaceConfig | Open or create workspace .vim/coc-settings.json. |
| tinymist.explainConfig | Show resolved server, client, and Coc-only config. |
| tinymist.migrateConfig | Copy legacy Tinymist config keys to current coc-tinymist keys. |
| tinymist.resetManagedServer | Remove the managed Tinymist binary and release metadata. |
| tinymist.useManagedServer | Clear serverPath and use the managed Tinymist binary. |
| tinymist.useSystemServer | Point serverPath at tinymist from $PATH. |
| tinymist.useCustomServer | Prompt for a custom Tinymist executable path. |
Preview
| Command | Description |
| --- | --- |
| typst-preview.browser | Open the current Typst document in Tinymist's browser preview. |
| typst-preview.startPreview | Alias for browser preview; Coc does not embed the VS Code webview. |
| typst-preview.browser-slide | Open the current Typst document in browser slide preview. |
| typst-preview.preview-slide | Alias for browser slide preview. |
| tinymist.browsingPreview | Open a browser preview that follows Tinymist's browsing-main-file behavior. |
| typst-preview.sync | Scroll the active browser preview to the current source cursor. |
| tinymist.stopPreview | Stop active Tinymist browser preview tasks. |
Export and Documents
| Command | Description |
| --- | --- |
| tinymist.export | Pick an export format for the current Typst document. |
| tinymist.exportTo | Pick a format and relocate the generated artifact. |
| tinymist.exportAndOpen | Pick a format and open the generated artifact. |
| tinymist.exportRepeat | Repeat the last Tinymist export. |
| tinymist.exportCopyPath | Copy the first path from the last export result. |
| tinymist.exportCurrentPdf | Export the current document as PDF. |
| tinymist.exportCurrentSvg | Export the current document as SVG. |
| tinymist.exportCurrentPng | Export the current document as PNG. |
| tinymist.exportCurrentHtml | Export the current document as HTML. |
| tinymist.exportCurrentMarkdown | Export the current document as Markdown. |
| tinymist.exportCurrentText | Export the current document as text. |
| tinymist.profileCurrentFile | Write current document trace data to a temp JSON file and the Tinymist Commands output channel. |
| tinymist.onEnter | Run Tinymist's experimental on-enter edit for comments/equations. |
Main Document
| Command | Description |
| --- | --- |
| tinymist.pinCurrentAsMain | Pin the current Typst document as main. |
| tinymist.selectMain | Pick a Typst file to pin as main. |
| tinymist.detectMain | Detect likely main files such as main.typ, thesis.typ, manifest entries, and setup files. |
| tinymist.showMain | Show the pinned main file. |
| tinymist.clearMain | Clear the pinned main file. |
Templates
| Command | Description |
| --- | --- |
| tinymist.showTemplateGallery | Open :CocList tinymistTemplates. |
| tinymist.refreshTemplates | Refresh the Typst Universe template cache. |
| tinymist.initTemplate | Initialize a Typst project from a template package spec. |
| tinymist.initTemplateVersion | Pick a template and initialize a specific version. |
| tinymist.initTemplateInPlace | Insert a template entry file at the cursor. |
Tasks and Diagnostics
| Command | Description |
| --- | --- |
| tinymist.testCurrent | Run tinymist test for the current file. |
| tinymist.testWorkspace | Run tinymist test for Typst files under the workspace. |
| tinymist.coverageCurrent | Run tinymist test --coverage for the current file. |
| tinymist.coverageOpenReport | Open the latest Tinymist coverage report artifact. |
| tinymist.tasks | Open the Tinymist task history list. |
| tinymist.taskRerunLast | Rerun the most recent rerunnable Tinymist task. |
| tinymist.taskOpenLastOutput | Open the output view for the most recent Tinymist task. |
| tinymist.taskClearHistory | Clear structured Tinymist task history. |
| tinymist.taskCancelRunning | Cancel running CLI-backed Tinymist tasks. |
| tinymist.lintToLocationList | Populate the location list from current Typst/Tinymist diagnostics. |
Lists
Run lists with :CocList.
| List | Description |
| --- | --- |
| tinymistTemplates | Browse Typst Universe templates and initialize or insert one. |
| tinymistTasks | Inspect task history, rerun tasks, open artifacts, copy commands, and populate the location list. |
| tinymistExports | Inspect export history, open artifacts, copy paths, repeat exports, or relocate an export. |
The template gallery fetches https://packages.typst.org/preview/index.json and caches the latest successful response in Coc global state. If the network is unavailable and no cache exists, tinymist.initTemplate and tinymist.initTemplateInPlace still accept a manually entered package spec.
Troubleshooting
Start with:
:CocCommand tinymist.doctorFor issue reports, prefer:
:CocCommand tinymist.doctorCopyIssueTemplateThe copied report redacts proxy credentials, token-like environment keys and values, and configured paths where possible.
Common fixes:
- Wrong or stale server path: run
tinymist.useManagedServer,tinymist.useSystemServer, ortinymist.useCustomServer, then restart. - Duplicate diagnostics/actions: run
tinymist.checkDuplicateServerand remove any manuallanguageserver.tinymistconfig. - Managed download behind a proxy: configure Coc's
http.proxyandhttp.proxyStrictSSL; managed downloads and template gallery requests use those settings. - Command says Tinymist is not running: run
tinymist.showLog,tinymist.showStatus, andtinymist.doctor, then restart. - Export succeeds without a visible artifact path: open the
Tinymist Commandsoutput channel, or usetinymist.exportTowhen you need a specific destination. - Browser preview does not follow the cursor automatically: run
typst-preview.sync, or set"tinymist.preview.scrollSync": "onSelectionChange". - Coverage report is missing: rerun
tinymist.coverageCurrent; staletarget/coverage.jsonfiles are ignored. - Enter handling does nothing: set
"tinymist.onEnterEvent": true.
File-sensitive commands such as export, test, profile, template insertion, and pin-current-main require a file-backed Typst buffer.
VS Code-only Tinymist settings such as webview preview, drag/drop, and paste handling are intentionally omitted. Coc preview support opens Tinymist's browser preview and supports source-to-preview and preview-to-source synchronization.
Development
npm install
npm run typecheck
npm test
npm run qa:commands
npm run qa:coc
npm run qa:lsp
npm pack --dry-runnpm test builds the extension and runs unit, lifecycle, server manager, update manager, export, activation, mocked Coc-host, downloader, and fake Tinymist LSP tests.
npm run qa:coc runs a headless Neovim/Coc smoke test that loads this extension and checks contributed commands/lists. npm run qa:lsp runs the real Tinymist LSP smoke test when tinymist is on $PATH or TINYMIST_BIN is set.
For a manual smoke test, open fixtures/sample.typ in Neovim with Coc enabled and check:
:CocCommand tinymist.serverVersion
:CocCommand tinymist.doctor
:CocCommand tinymist.exportCurrentPdf
:CocCommand tinymist.showStatus
:CocList tinymistExports
:CocList tinymistTasks
:CocList tinymistTemplatesAlso verify standard Coc LSP actions such as hover, definition, references, rename, formatting, code actions, diagnostics, document symbols, and semantic tokens.
License
MIT
Built with create-coc-extension and following Coc extension README conventions from coc-texlab and coc-rust-analyzer.
