coc-tinymist 0.1.0 → 0.1.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +239 -142
  2. package/lib/index.js +134 -0
  3. package/package.json +6 -1
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # coc-tinymist
2
2
 
3
- Typst language support for coc.nvim powered by [Tinymist](https://github.com/Myriad-Dreamin/tinymist).
3
+ Typst language support for [coc.nvim](https://github.com/neoclide/coc.nvim), powered by
4
+ [Tinymist](https://github.com/Myriad-Dreamin/tinymist).
4
5
 
5
6
  ## Install
6
7
 
@@ -8,190 +9,281 @@ Typst language support for coc.nvim powered by [Tinymist](https://github.com/Myr
8
9
  :CocInstall coc-tinymist
9
10
  ```
10
11
 
11
- Open a `typst` buffer. If `tinymist` is not available from `tinymist.serverPath`, the extension's managed storage, or `$PATH`, coc-tinymist can download the latest Tinymist release from GitHub.
12
+ Then open a `.typ` file. If no Tinymist executable is configured, coc-tinymist can download a managed Tinymist release on first use.
13
+
14
+ ## Server Setup
15
+
16
+ coc-tinymist resolves the server in this order:
17
+
18
+ 1. `tinymist.serverPath`
19
+ 2. the extension-managed Tinymist binary
20
+ 3. `tinymist` from `$PATH`
21
+
22
+ 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.
23
+
24
+ ```jsonc
25
+ {
26
+ "tinymist.updates.mode": "prompt"
27
+ }
28
+ ```
29
+
30
+ Useful server commands:
31
+
32
+ ```vim
33
+ :CocCommand tinymist.install
34
+ :CocCommand tinymist.update
35
+ :CocCommand tinymist.useManagedServer
36
+ :CocCommand tinymist.useSystemServer
37
+ :CocCommand tinymist.useCustomServer
38
+ :CocCommand tinymist.restartServer
39
+ :CocCommand tinymist.serverVersion
40
+ ```
41
+
42
+ If you already have a manual `languageserver.tinymist` entry in `coc-settings.json`, remove it or run:
43
+
44
+ ```vim
45
+ :CocCommand tinymist.checkDuplicateServer
46
+ ```
12
47
 
13
48
  ## Configuration
14
49
 
15
- Common settings in `coc-settings.json`:
50
+ Put settings in `:CocConfig` or a workspace `.vim/coc-settings.json`.
16
51
 
17
52
  ```jsonc
18
53
  {
19
- "semanticTokens.enable": false,
20
- "[typst]": {
21
- "semanticTokens.enable": true
22
- },
23
54
  "tinymist.enable": true,
55
+ "tinymist.updates.mode": "prompt",
24
56
  "tinymist.serverPath": null,
25
57
  "tinymist.serverArgs": ["lsp"],
26
- "tinymist.updates.mode": "prompt",
27
- "tinymist.rootPath": null,
28
- "tinymist.outputPath": "",
29
- "tinymist.exportTarget": "paged",
58
+
30
59
  "tinymist.formatterMode": "typstyle",
31
60
  "tinymist.formatterPrintWidth": 120,
32
- "tinymist.fontPaths": null,
33
- "tinymist.systemFonts": true,
34
- "tinymist.exportPdf": "never",
61
+
35
62
  "tinymist.exportOnSave": [],
36
- "tinymist.exportOnType": [],
37
- "tinymist.exportOnIdle": [],
38
- "tinymist.exportOpenAfterSave": false,
39
63
  "tinymist.exportOutputDirectory": null,
40
- "tinymist.exportShowIn": "message",
41
- "tinymist.lint.enabled": false,
42
- "tinymist.lint.when": "onSave",
43
- "tinymist.semanticTokens": "enable",
44
- "tinymist.inlayHints.packageVersionStatus": true,
45
- "tinymist.cocFallbackDocumentHighlight": true,
46
- "tinymist.cocFallbackInlayHints": false,
47
- "tinymist.fallback.maxFileBytes": 524288,
48
- "tinymist.fallback.maxHighlights": 500,
49
- "tinymist.fallback.maxInlayHints": 500,
50
- "tinymist.onEnterEvent": false,
64
+
51
65
  "tinymist.compileStatus": "disable",
52
- "tinymist.statusBarFormat": "{compileStatusIcon} {wordCount} [{fileName}]",
53
- "tinymist.mainFile.store": "workspaceState",
54
- "tinymist.tasks.workspaceFileLimit": 100,
55
- "tinymist.tasks.workspaceTimeoutMs": 120000,
56
- "tinymist.tasks.fileTimeoutMs": 30000,
57
- "tinymist.tasks.maxOutputBytes": 1048576,
58
- "tinymist.tasks.progressIntervalMs": 2000,
59
- "tinymist.commands.exportTimeoutMs": 120000,
60
- "tinymist.commands.profileTimeoutMs": 120000,
61
- "tinymist.commands.templateTimeoutMs": 60000,
62
- "tinymist.markdown.isTrusted": false,
63
- "tinymist.markdown.supportHtml": false
66
+ "tinymist.statusBarFormat": "{compileStatusIcon} {wordCount} [{fileName}]"
64
67
  }
65
68
  ```
66
69
 
67
- Set `"tinymist.updates.mode": "never"` to disable managed downloads and only use a configured or system Tinymist executable. Use `"manual"` to install/update only when running `tinymist.install` or `tinymist.update`, `"prompt"` to ask first, or `"auto"` to download without prompting.
68
-
69
- Managed Tinymist downloads currently support macOS arm64/x64, Linux x64 GNU/musl, Linux arm64 GNU, Linux armv7 GNU, and Windows x64/arm64. On other platforms, install Tinymist yourself and point `tinymist.serverPath` at that executable.
70
-
71
- Set `"tinymist.compileStatus": "enable"` to opt into the status bar item for compile state, word count, and current file. Set `"tinymist.statusBarFormat": ""` to keep notifications enabled while hiding the item.
72
-
73
- Set `"semanticTokens.enable": true` under the `[typst]` language override to let Coc render semantic token highlights for Typst without enabling them globally. `tinymist.semanticTokens` controls whether Tinymist provides semantic token data to Coc; it does not override Coc's semantic highlighting gate. Use `:CocCommand semanticTokens.checkCurrent` to inspect whether Coc is applying semantic highlights in the current buffer, and `:CocCommand semanticTokens.refreshCurrent` after changing highlight groups.
70
+ All configuration keys are contributed to Coc's JSON schema and grouped below.
71
+
72
+ ### Server
73
+
74
+ | Setting | Default | Description |
75
+ | --- | --- | --- |
76
+ | `tinymist.enable` | `true` | Enable coc-tinymist. |
77
+ | `tinymist.serverPath` | `null` | Absolute path to a Tinymist executable. When unset, coc-tinymist uses a managed binary or `$PATH`. |
78
+ | `tinymist.serverArgs` | `["lsp"]` | Arguments passed to Tinymist. |
79
+ | `tinymist.serverExtraEnv` | `null` | Extra environment variables for Tinymist. |
80
+ | `tinymist.restartServerOnConfigChange` | `false` | Restart Tinymist when process-level settings change. |
81
+ | `tinymist.trace.server` | `"off"` | Trace LSP traffic: `off`, `messages`, or `verbose`. |
82
+ | `tinymist.updates.mode` | `"prompt"` | Managed server install/update mode: `prompt`, `auto`, `manual`, or `never`. |
83
+ | `tinymist.updates.checkOnStartup` | `true` | Check managed server updates on startup. |
84
+ | `tinymist.updates.prompt` | `true` | Deprecated. Use `tinymist.updates.mode` instead. |
85
+
86
+ ### Project and Compiler
87
+
88
+ | Setting | Default | Description |
89
+ | --- | --- | --- |
90
+ | `tinymist.projectResolution` | `"singleFile"` | Use the focused file as the project entry or Tinymist's lock database. |
91
+ | `tinymist.syntaxOnly` | `"auto"` | Control Tinymist syntax-only mode. |
92
+ | `tinymist.rootPath` | `null` | Root path for Typst compilation. |
93
+ | `tinymist.outputPath` | `""` | Tinymist output path pattern. |
94
+ | `tinymist.exportTarget` | `"paged"` | Default Tinymist export target: `paged`, `html`, or `bundle`. |
95
+ | `tinymist.typstExtraArgs` | `[]` | Extra Typst CLI-shaped arguments parsed by Tinymist. |
96
+ | `tinymist.systemFonts` | `true` | Load system fonts in Tinymist's shared compiler environment. |
97
+ | `tinymist.fontPaths` | `null` | Font files or directories for Tinymist. |
98
+
99
+ ### Formatting and Language Features
100
+
101
+ | Setting | Default | Description |
102
+ | --- | --- | --- |
103
+ | `tinymist.formatterMode` | `"typstyle"` | Formatter backend: `disable`, `typstyle`, or `typstfmt`. |
104
+ | `tinymist.formatterPrintWidth` | `120` | Soft print-width limit. |
105
+ | `tinymist.formatterIndentSize` | `2` | Formatter indent size. |
106
+ | `tinymist.formatterProseWrap` | `false` | Hard-wrap prose at the configured print width. |
107
+ | `tinymist.semanticTokens` | `"enable"` | Enable Tinymist semantic token data. Coc highlighting still requires `semanticTokens.enable`. |
108
+ | `tinymist.inlayHints.packageVersionStatus` | `true` | Show package version status hints when Coc inlay hints are enabled. |
109
+ | `tinymist.cocFallbackDocumentHighlight` | `true` | Use Coc-side exact-match highlights only when Tinymist returns no highlights. |
110
+ | `tinymist.cocFallbackInlayHints` | `false` | Add simple Coc-side Typst function parameter hints. |
111
+ | `tinymist.fallback.maxFileBytes` | `524288` | Maximum document size for Coc-side fallback parsing. |
112
+ | `tinymist.fallback.maxHighlights` | `500` | Maximum fallback document highlights per request. |
113
+ | `tinymist.fallback.maxInlayHints` | `500` | Maximum fallback inlay hints per request. |
114
+ | `tinymist.onEnterEvent` | `false` | Enable Coc-side Enter handling through Tinymist `experimental/onEnter`. |
115
+ | `tinymist.typingContinueCommentsOnNewline` | `true` | Continue Typst comments when Coc-side Enter handling is enabled. |
116
+ | `tinymist.lint.enabled` | `false` | Enable Tinymist lint diagnostics. |
117
+ | `tinymist.lint.when` | `"onSave"` | Run linting on save or typing. |
118
+
119
+
120
+ ### Export, Tasks, and Status
121
+
122
+ | Setting | Default | Description |
123
+ | --- | --- | --- |
124
+ | `tinymist.exportOnSave` | `[]` | Extension-side automatic exports after save. Use `true`, `"Pdf"`, or an array like `["Pdf", "Html"]`. |
125
+ | `tinymist.exportOnType` | `[]` | Extension-side automatic exports after typing changes. |
126
+ | `tinymist.exportOnIdle` | `[]` | Extension-side automatic exports after the document is idle. |
127
+ | `tinymist.exportPdf` | `"never"` | Tinymist server-side PDF export trigger: `never`, `onSave`, `onType`, or `onDocumentHasTitle`. |
128
+ | `tinymist.exportOutputDirectory` | `null` | Directory for automatic export artifacts. |
129
+ | `tinymist.exportOpenAfterSave` | `false` | Open the first save-triggered export artifact. |
130
+ | `tinymist.exportShowIn` | `"message"` | Show automatic export results in `none`, `message`, `output`, `quickfix`, or `open`. |
131
+ | `tinymist.mainFile.store` | `"workspaceState"` | Persist pinned main files per workspace, or use `none` for memory-only pinning. |
132
+ | `tinymist.tasks.workspaceFileLimit` | `100` | Maximum `.typ` files for workspace tests. |
133
+ | `tinymist.tasks.workspaceTimeoutMs` | `120000` | Workspace task timeout. |
134
+ | `tinymist.tasks.fileTimeoutMs` | `30000` | Per-file task timeout. |
135
+ | `tinymist.tasks.maxOutputBytes` | `1048576` | Captured stdout/stderr limit per stream. |
136
+ | `tinymist.tasks.progressIntervalMs` | `2000` | Minimum interval between workspace task progress updates. |
137
+ | `tinymist.commands.exportTimeoutMs` | `120000` | Timeout for Tinymist export execute-command requests. |
138
+ | `tinymist.commands.profileTimeoutMs` | `120000` | Timeout for Tinymist profile execute-command requests. |
139
+ | `tinymist.commands.templateTimeoutMs` | `60000` | Timeout for Tinymist template execute-command requests. |
140
+ | `tinymist.compileStatus` | `"disable"` | Enable compile status notifications and the status item. |
141
+ | `tinymist.statusBarFormat` | `"{compileStatusIcon} {wordCount} [{fileName}]"` | Status item format. Set to `""` to hide the item while keeping notifications. |
142
+
143
+ `tinymist.exportTo` lets you choose a format and destination. Output paths can use `{name}`, `{ext}`, `{kind}`, `{index}`, `{page}`, `{hash}`, and `{relativeDir}` placeholders:
74
144
 
75
- Set `"tinymist.onEnterEvent": true` to opt into coc-tinymist's insert-mode Enter handler for comment and equation continuation. Document-highlight fallback only runs when Tinymist returns no highlights. Inlay fallback is off by default because it is additive to Tinymist's own hints; enable it with `tinymist.cocFallbackInlayHints`. Fallback parsing is cached per document version and skipped above `tinymist.fallback.maxFileBytes`; per-request result caps are controlled by `tinymist.fallback.maxHighlights` and `tinymist.fallback.maxInlayHints`.
145
+ ```jsonc
146
+ {
147
+ "tinymist.outputPath": "build/{relativeDir}/{name}-{page}.{ext}"
148
+ }
149
+ ```
76
150
 
77
- The schema also includes Tinymist project resolution, syntax-only mode, formatter indent/prose wrapping, `typstExtraArgs`, and `typingContinueCommentsOnNewline`. VS Code-only settings such as webview preview, drag/drop, and paste handling are intentionally omitted.
151
+ If a multi-file export targets `slides.png`, coc-tinymist writes `slides.png`, `slides-2.png`, `slides-3.png`, and so on.
78
152
 
79
- Markdown returned by Tinymist is untrusted and raw HTML rendering is disabled by default. Set `"tinymist.markdown.isTrusted": true` only if you want command links in server-provided Markdown to be executable. Set `"tinymist.markdown.supportHtml": true` only if you trust documentation generated from the current project and installed packages.
153
+ ### Markdown Trust
80
154
 
81
- `tinymist.exportTo` now attempts to pass a literal `outputPath` option through Tinymist's `workspace/executeCommand` export call. If the server ignores or rejects that option, coc-tinymist finalizes the result itself. Path artifacts are copied through temporary sibling files and atomically renamed into place where the platform allows it; inline `data` artifacts are written the same way. If a multi-file export targets `slides.png`, coc-tinymist writes `slides.png`, `slides-2.png`, `slides-3.png`, and so on. If the target has no extension, it is treated as a directory and Tinymist-generated basenames are preserved when available.
155
+ | Setting | Default | Description |
156
+ | --- | --- | --- |
157
+ | `tinymist.markdown.isTrusted` | `false` | Trust Markdown returned by Tinymist. Enable only if you want command links in server-provided Markdown to run. |
158
+ | `tinymist.markdown.supportHtml` | `false` | Render raw HTML in Tinymist Markdown. Enable only for trusted projects and packages. |
82
159
 
83
- Export target paths may use `{name}`, `{ext}`, `{kind}`, `{index}`, `{page}`, `{hash}`, and `{relativeDir}` placeholders. For example, `build/{relativeDir}/{name}-{hash}-{page}.{ext}` keeps artifacts from different source folders from colliding.
160
+ ## Commands
84
161
 
85
- For extension-side automatic exports, set `tinymist.exportOnSave`, `tinymist.exportOnType`, or `tinymist.exportOnIdle` to `true` for PDF, a single format such as `"Pdf"`, or an array such as `["Pdf", "Html"]`. Use `tinymist.exportOutputDirectory` to relocate automatic export artifacts, `tinymist.exportOpenAfterSave` to open save-triggered artifacts, and `tinymist.exportShowIn` to choose `none`, `message`, `output`, `quickfix`, or `open`.
162
+ Run commands with `:CocCommand`.
86
163
 
87
- Automatic exports are serialized per source file, output format, and target path. If another save/type/idle event arrives while an export is running, coc-tinymist reruns once after the active export finishes so the final document state is not dropped.
164
+ ### Server and Config
88
165
 
89
- Pinned main documents are stored per workspace by default with `tinymist.mainFile.store: "workspaceState"` and restored after server startup/restart. Set it to `"none"` for in-memory-only pinning. `tinymist.detectMain` ranks obvious candidates such as `main.typ`, `thesis.typ`, `paper.typ`, Typst manifest entry points, and files with document setup rules.
166
+ | Command | Description |
167
+ | --- | --- |
168
+ | `tinymist.actions` | Pick from grouped Tinymist actions. |
169
+ | `tinymist.restartServer` | Restart the Tinymist language server. |
170
+ | `tinymist.install` | Install Tinymist from GitHub releases. |
171
+ | `tinymist.update` | Check for and install a managed Tinymist update. |
172
+ | `tinymist.serverVersion` | Show the active Tinymist version and source. |
173
+ | `tinymist.showStatus` | Show the latest Tinymist status details. |
174
+ | `tinymist.showLog` | Open the Tinymist language server log. |
175
+ | `tinymist.doctor` | Open a diagnostic report for server, config, workspace, and status. |
176
+ | `tinymist.doctorCopyIssueTemplate` | Copy a sanitized issue report to the clipboard. |
177
+ | `tinymist.doctorSaveReport` | Save a sanitized doctor report to a temp file. |
178
+ | `tinymist.checkDuplicateServer` | Check for a duplicate manual `languageserver.tinymist` config. |
179
+ | `tinymist.openConfig` | Open user `coc-settings.json`. |
180
+ | `tinymist.openWorkspaceConfig` | Open or create workspace `.vim/coc-settings.json`. |
181
+ | `tinymist.explainConfig` | Show resolved server, client, and Coc-only config. |
182
+ | `tinymist.migrateConfig` | Copy legacy Tinymist config keys to current coc-tinymist keys. |
183
+ | `tinymist.resetManagedServer` | Remove the managed Tinymist binary and release metadata. |
184
+ | `tinymist.useManagedServer` | Clear `serverPath` and use the managed Tinymist binary. |
185
+ | `tinymist.useSystemServer` | Point `serverPath` at `tinymist` from `$PATH`. |
186
+ | `tinymist.useCustomServer` | Prompt for a custom Tinymist executable path. |
187
+
188
+ ### Export and Documents
90
189
 
91
- File-sensitive commands such as export, test, profile, template insertion, and pin-current-main require a file-backed Typst buffer. Coverage task results only attach `target/coverage.json` when the report was written during the current coverage run.
190
+ | Command | Description |
191
+ | --- | --- |
192
+ | `tinymist.export` | Pick an export format for the current Typst document. |
193
+ | `tinymist.exportTo` | Pick a format and relocate the generated artifact. |
194
+ | `tinymist.exportAndOpen` | Pick a format and open the generated artifact. |
195
+ | `tinymist.exportRepeat` | Repeat the last Tinymist export. |
196
+ | `tinymist.exportCopyPath` | Copy the first path from the last export result. |
197
+ | `tinymist.exportCurrentPdf` | Export the current document as PDF. |
198
+ | `tinymist.exportCurrentSvg` | Export the current document as SVG. |
199
+ | `tinymist.exportCurrentPng` | Export the current document as PNG. |
200
+ | `tinymist.exportCurrentHtml` | Export the current document as HTML. |
201
+ | `tinymist.exportCurrentMarkdown` | Export the current document as Markdown. |
202
+ | `tinymist.exportCurrentText` | Export the current document as text. |
203
+ | `tinymist.profileCurrentFile` | Write current document trace data to a temp JSON file and the Tinymist Commands output channel. |
204
+ | `tinymist.onEnter` | Run Tinymist's experimental on-enter edit for comments/equations. |
205
+
206
+ ### Main Document
92
207
 
93
- CLI-backed tasks respect `tinymist.tasks.workspaceFileLimit`, `tinymist.tasks.workspaceTimeoutMs`, `tinymist.tasks.fileTimeoutMs`, `tinymist.tasks.maxOutputBytes`, and `tinymist.tasks.progressIntervalMs`. Use `tinymist.taskCancelRunning` to abort running CLI-backed task subprocesses. LSP command-backed export/profile/template actions use `tinymist.commands.exportTimeoutMs`, `tinymist.commands.profileTimeoutMs`, and `tinymist.commands.templateTimeoutMs`.
208
+ | Command | Description |
209
+ | --- | --- |
210
+ | `tinymist.pinCurrentAsMain` | Pin the current Typst document as main. |
211
+ | `tinymist.selectMain` | Pick a Typst file to pin as main. |
212
+ | `tinymist.detectMain` | Detect likely main files such as `main.typ`, `thesis.typ`, manifest entries, and setup files. |
213
+ | `tinymist.showMain` | Show the pinned main file. |
214
+ | `tinymist.clearMain` | Clear the pinned main file. |
94
215
 
95
- Server source commands such as `tinymist.useManagedServer`, `tinymist.useSystemServer`, and `tinymist.useCustomServer` prompt for the configuration scope before writing `tinymist.serverPath`: Global, Workspace, or Workspace Folder.
216
+ ### Templates
96
217
 
97
- ## Commands
218
+ | Command | Description |
219
+ | --- | --- |
220
+ | `tinymist.showTemplateGallery` | Open `:CocList tinymistTemplates`. |
221
+ | `tinymist.refreshTemplates` | Refresh the Typst Universe template cache. |
222
+ | `tinymist.initTemplate` | Initialize a Typst project from a template package spec. |
223
+ | `tinymist.initTemplateVersion` | Pick a template and initialize a specific version. |
224
+ | `tinymist.initTemplateInPlace` | Insert a template entry file at the cursor. |
98
225
 
99
- Use these with `:CocCommand`:
226
+ ### Tasks and Diagnostics
100
227
 
101
228
  | Command | Description |
102
229
  | --- | --- |
103
- | `tinymist.restartServer` | Restart the Tinymist language server |
104
- | `tinymist.install` | Install Tinymist from the latest GitHub release |
105
- | `tinymist.update` | Check for and install the latest managed Tinymist release |
106
- | `tinymist.serverVersion` | Show the active Tinymist version |
107
- | `tinymist.doctor` | Open a diagnostic report for server, config, workspace, and status |
108
- | `tinymist.doctorCopyIssueTemplate` | Copy a sanitized markdown issue report to the clipboard |
109
- | `tinymist.doctorSaveReport` | Save a sanitized markdown doctor report to a temp file |
110
- | `tinymist.checkDuplicateServer` | Check for a duplicate manual `languageserver.tinymist` config |
111
- | `tinymist.openConfig` | Open the user `coc-settings.json` file |
112
- | `tinymist.openWorkspaceConfig` | Open or create `.vim/coc-settings.json` under the current workspace |
113
- | `tinymist.explainConfig` | Show resolved Tinymist server config, client flags, and Coc-only settings |
114
- | `tinymist.migrateConfig` | Copy legacy Tinymist config keys to current coc-tinymist keys |
115
- | `tinymist.resetManagedServer` | Remove the managed Tinymist binary and release metadata |
116
- | `tinymist.useSystemServer` | Point `tinymist.serverPath` at the Tinymist executable found on `$PATH` |
117
- | `tinymist.useManagedServer` | Clear `tinymist.serverPath` and use the managed Tinymist binary |
118
- | `tinymist.useCustomServer` | Prompt for a custom Tinymist executable path |
119
- | `tinymist.actions` | Pick from grouped Tinymist actions for export, tasks, main files, templates, diagnostics, server, and config |
120
- | `tinymist.showStatus` | Show the latest Tinymist status details |
121
- | `tinymist.showLog` | Show the Tinymist language server log |
122
- | `tinymist.showTemplateGallery` | Open `CocList tinymistTemplates` |
123
- | `tinymist.refreshTemplates` | Refresh the Typst Universe template cache |
124
- | `tinymist.initTemplate` | Initialize a Typst project from a template package spec |
125
- | `tinymist.initTemplateVersion` | Pick a template and initialize a specific version |
126
- | `tinymist.initTemplateInPlace` | Insert a template entry file at the cursor |
127
- | `tinymist.export` | Pick an export format for the current Typst document |
128
- | `tinymist.exportTo` | Pick an export format and relocate the generated artifact to an output path |
129
- | `tinymist.exportAndOpen` | Pick an export format and open the generated artifact |
130
- | `tinymist.exportRepeat` | Repeat the last Tinymist export with the same format and options |
131
- | `tinymist.exportCopyPath` | Copy the first path from the last Tinymist export result |
132
- | `tinymist.exportCurrentPdf` | Export the current Typst document as PDF |
133
- | `tinymist.exportCurrentSvg` | Export the current Typst document as SVG |
134
- | `tinymist.exportCurrentPng` | Export the current Typst document as PNG |
135
- | `tinymist.exportCurrentHtml` | Export the current Typst document as HTML |
136
- | `tinymist.exportCurrentMarkdown` | Export the current Typst document as Markdown |
137
- | `tinymist.exportCurrentText` | Export the current Typst document as text |
138
- | `tinymist.profileCurrentFile` | Write current document trace data to a temp JSON file and the Tinymist Commands output channel |
139
- | `tinymist.pinCurrentAsMain` | Pin the current Typst document as main |
140
- | `tinymist.selectMain` | Pick a Typst file to pin as main |
141
- | `tinymist.showMain` | Show the currently pinned main file tracked by coc-tinymist |
142
- | `tinymist.clearMain` | Clear the pinned Tinymist main file |
143
- | `tinymist.detectMain` | Detect likely main Typst files and pin the selected candidate |
144
- | `tinymist.testCurrent` | Run `tinymist test` for the current file and record the task result |
145
- | `tinymist.testWorkspace` | Run `tinymist test` for Typst files under the workspace, capped at 100 files |
146
- | `tinymist.coverageCurrent` | Run `tinymist test --coverage` for the current file and record the task result plus `target/coverage.json` when produced |
147
- | `tinymist.tasks` | Open the Tinymist task history list |
148
- | `tinymist.taskRerunLast` | Rerun the most recent rerunnable Tinymist task |
149
- | `tinymist.taskOpenLastOutput` | Open the output view for the most recent Tinymist task |
150
- | `tinymist.taskClearHistory` | Clear structured Tinymist task history |
151
- | `tinymist.taskCancelRunning` | Cancel running CLI-backed Tinymist tasks |
152
- | `tinymist.lintToLocationList` | Populate the location list from current Typst/Tinymist diagnostics |
153
- | `tinymist.coverageOpenReport` | Open the latest Tinymist coverage report artifact |
154
- | `tinymist.onEnter` | Run Tinymist's experimental on-enter edit for comments/equations |
230
+ | `tinymist.testCurrent` | Run `tinymist test` for the current file. |
231
+ | `tinymist.testWorkspace` | Run `tinymist test` for Typst files under the workspace. |
232
+ | `tinymist.coverageCurrent` | Run `tinymist test --coverage` for the current file. |
233
+ | `tinymist.coverageOpenReport` | Open the latest Tinymist coverage report artifact. |
234
+ | `tinymist.tasks` | Open the Tinymist task history list. |
235
+ | `tinymist.taskRerunLast` | Rerun the most recent rerunnable Tinymist task. |
236
+ | `tinymist.taskOpenLastOutput` | Open the output view for the most recent Tinymist task. |
237
+ | `tinymist.taskClearHistory` | Clear structured Tinymist task history. |
238
+ | `tinymist.taskCancelRunning` | Cancel running CLI-backed Tinymist tasks. |
239
+ | `tinymist.lintToLocationList` | Populate the location list from current Typst/Tinymist diagnostics. |
155
240
 
156
241
  ## Lists
157
242
 
158
- Use these with `:CocList`:
243
+ Run lists with `:CocList`.
159
244
 
160
245
  | List | Description |
161
246
  | --- | --- |
162
- | `tinymistTemplates` | Browse Typst Universe templates and initialize or insert one |
163
- | `tinymistTasks` | Inspect task history, rerun tasks, open artifacts, copy commands, and populate the location list |
164
- | `tinymistExports` | Inspect export history, open artifacts, copy paths, repeat exports, or relocate an export |
165
-
166
- The template list fetches `https://packages.typst.org/preview/index.json` and filters packages with template metadata. The latest successful gallery response is cached in Coc global state for offline browsing. If the network is unavailable and no cache exists, `tinymist.initTemplate` and `tinymist.initTemplateInPlace` still accept a manually entered package spec. The list actions include `init`, `in-place`, `details`, `version`, and `refresh`.
247
+ | `tinymistTemplates` | Browse Typst Universe templates and initialize or insert one. |
248
+ | `tinymistTasks` | Inspect task history, rerun tasks, open artifacts, copy commands, and populate the location list. |
249
+ | `tinymistExports` | Inspect export history, open artifacts, copy paths, repeat exports, or relocate an export. |
167
250
 
168
- Task runs are stored in memory as structured records with command, target, timestamps, status, raw result, message, and artifact paths. The task list actions are `open-output`, `rerun`, `copy-command`, `clear`, `open-artifact`, and `populate-location-list`; long CLI-backed tasks can be cancelled with `tinymist.taskCancelRunning`. `tinymist.lintToLocationList` uses the current Coc diagnostics because Tinymist lint feedback is delivered through LSP diagnostics rather than a separate one-shot command. The export list actions are `open`, `reveal/copy-path`, `repeat`, and `export-to`.
251
+ 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.
169
252
 
170
253
  ## Troubleshooting
171
254
 
172
- Run `:CocCommand tinymist.doctor` first. For issue reports, prefer `:CocCommand tinymist.doctorCopyIssueTemplate`; it redacts proxy credentials, token-like environment keys and values, and configured paths where possible.
255
+ Start with:
173
256
 
174
- If `tinymist.serverPath` is wrong or stale, coc-tinymist keeps the extension loaded and reports the invalid path. Run `:CocCommand tinymist.useManagedServer`, `:CocCommand tinymist.useSystemServer`, or `:CocCommand tinymist.useCustomServer` to repair the server source, then run `:CocCommand tinymist.restartServer`.
175
-
176
- If managed install says your platform is unsupported, install Tinymist manually and set `tinymist.serverPath`. Managed downloads currently cover the platforms listed above, not every target that Tinymist may publish.
257
+ ```vim
258
+ :CocCommand tinymist.doctor
259
+ ```
177
260
 
178
- If you are behind a corporate proxy, configure Coc's `http.proxy` and `http.proxyStrictSSL` settings. Managed release metadata, checksums, binary downloads, and the Typst Universe template gallery all use those proxy settings.
261
+ For issue reports, prefer:
179
262
 
180
- If Tinymist appears to start twice or diagnostics/actions duplicate, run `:CocCommand tinymist.checkDuplicateServer` and remove any manual `languageserver.tinymist` entry from `coc-settings.json`.
263
+ ```vim
264
+ :CocCommand tinymist.doctorCopyIssueTemplate
265
+ ```
181
266
 
182
- If commands say Tinymist is not running, run `:CocCommand tinymist.showLog`, `:CocCommand tinymist.showStatus`, and `:CocCommand tinymist.doctor`. Then try `:CocCommand tinymist.restartServer`.
267
+ The copied report redacts proxy credentials, token-like environment keys and values, and configured paths where possible.
183
268
 
184
- If an export succeeds but reports no artifact path, open the `Tinymist Commands` output channel. Some server responses may return inline data or no path; `tinymist.exportTo` is the most predictable command when you need a specific artifact path.
269
+ Common fixes:
185
270
 
186
- If `tinymist.coverageOpenReport` finds no report, rerun `:CocCommand tinymist.coverageCurrent`. coc-tinymist intentionally ignores stale `target/coverage.json` files that were not produced by the current coverage run.
271
+ - Wrong or stale server path: run `tinymist.useManagedServer`, `tinymist.useSystemServer`, or `tinymist.useCustomServer`, then restart.
272
+ - Duplicate diagnostics/actions: run `tinymist.checkDuplicateServer` and remove any manual `languageserver.tinymist` config.
273
+ - Managed download behind a proxy: configure Coc's `http.proxy` and `http.proxyStrictSSL`; managed downloads and template gallery requests use those settings.
274
+ - Command says Tinymist is not running: run `tinymist.showLog`, `tinymist.showStatus`, and `tinymist.doctor`, then restart.
275
+ - Export succeeds without a visible artifact path: open the `Tinymist Commands` output channel, or use `tinymist.exportTo` when you need a specific destination.
276
+ - Coverage report is missing: rerun `tinymist.coverageCurrent`; stale `target/coverage.json` files are ignored.
277
+ - Enter handling does nothing: set `"tinymist.onEnterEvent": true`.
187
278
 
188
- The on-enter keymap is disabled by default. Set `"tinymist.onEnterEvent": true` to enable it.
279
+ File-sensitive commands such as export, test, profile, template insertion, and pin-current-main require a file-backed Typst buffer.
189
280
 
190
- ## Development QA
281
+ VS Code-only Tinymist settings such as webview preview, drag/drop, and paste handling are intentionally omitted.
191
282
 
192
- Run these before publishing:
283
+ ## Development
193
284
 
194
285
  ```sh
286
+ npm install
195
287
  npm run typecheck
196
288
  npm test
197
289
  npm run qa:commands
@@ -200,18 +292,23 @@ npm run qa:lsp
200
292
  npm pack --dry-run
201
293
  ```
202
294
 
203
- `npm test` builds the extension and runs unit tests, lifecycle integration tests, mocked Coc-host tests, downloader/archive tests, export tests, activation tests, and a fake Tinymist LSP smoke test. `npm run qa:coc` runs a headless Neovim/Coc smoke test that loads this extension, checks contributed commands/lists, and runs core commands. `npm run qa:lsp` runs the real Tinymist LSP smoke test when `tinymist` is available on `$PATH` or `TINYMIST_BIN` is set.
295
+ `npm test` builds the extension and runs unit, lifecycle, server manager, update manager, export, activation, mocked Coc-host, downloader, and fake Tinymist LSP tests.
296
+
297
+ `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.
204
298
 
205
- For a manual release smoke, open `fixtures/sample.typ` in Neovim with Coc enabled and verify:
299
+ For a manual smoke test, open `fixtures/sample.typ` in Neovim with Coc enabled and check:
300
+
301
+ ```vim
302
+ :CocCommand tinymist.serverVersion
303
+ :CocCommand tinymist.doctor
304
+ :CocCommand tinymist.exportCurrentPdf
305
+ :CocCommand tinymist.showStatus
306
+ :CocList tinymistExports
307
+ :CocList tinymistTasks
308
+ :CocList tinymistTemplates
309
+ ```
206
310
 
207
- - `:CocCommand tinymist.serverVersion`
208
- - `:CocCommand tinymist.doctor`
209
- - `:CocCommand tinymist.exportCurrentPdf`
210
- - `:CocCommand tinymist.showStatus`
211
- - `:CocList tinymistExports`
212
- - `:CocList tinymistTasks`
213
- - `:CocList tinymistTemplates`
214
- - standard Coc LSP actions such as hover, definition, references, rename, formatting, code actions, diagnostics, document symbols, and semantic tokens
311
+ Also verify standard Coc LSP actions such as hover, definition, references, rename, formatting, code actions, diagnostics, document symbols, and semantic tokens.
215
312
 
216
313
  ## License
217
314
 
@@ -219,4 +316,4 @@ MIT
219
316
 
220
317
  ---
221
318
 
222
- This extension is built with [create-coc-extension](https://github.com/fannheyward/create-coc-extension) and follows patterns from [coc-texlab](https://github.com/fannheyward/coc-texlab) and [coc-rust-analyzer](https://github.com/fannheyward/coc-rust-analyzer).
319
+ Built with [create-coc-extension](https://github.com/fannheyward/create-coc-extension) and following Coc extension README conventions from [coc-texlab](https://github.com/fannheyward/coc-texlab) and [coc-rust-analyzer](https://github.com/fannheyward/coc-rust-analyzer).
package/lib/index.js CHANGED
@@ -8183,6 +8183,12 @@ var TINYMIST_SETTING_DESCRIPTORS = [
8183
8183
  scope: "local",
8184
8184
  description: "Enable Coc-side inlay hint fallback."
8185
8185
  },
8186
+ {
8187
+ key: "completion.suppressBareHash",
8188
+ defaultValue: true,
8189
+ scope: "local",
8190
+ description: "Suppress Tinymist completions at a standalone bare #."
8191
+ },
8186
8192
  {
8187
8193
  key: "fallback.maxFileBytes",
8188
8194
  defaultValue: 524288,
@@ -8653,6 +8659,9 @@ var Config = class {
8653
8659
  get markdownSupportHtml() {
8654
8660
  return this.cfg.get("markdown.supportHtml", false);
8655
8661
  }
8662
+ get completionSuppressBareHash() {
8663
+ return this.cfg.get("completion.suppressBareHash", true);
8664
+ }
8656
8665
  get exportOnSave() {
8657
8666
  return readExportKinds(this.cfg.get("exportOnSave", []));
8658
8667
  }
@@ -9969,6 +9978,125 @@ var BinaryResolver = class {
9969
9978
 
9970
9979
  // src/client/index.ts
9971
9980
  var import_coc17 = require("coc.nvim");
9981
+
9982
+ // src/features/completion.ts
9983
+ function filterTinymistCompletions(document2, position, result, options = {}) {
9984
+ if (!result) {
9985
+ return result;
9986
+ }
9987
+ const linePrefix = lineTextBeforePosition(document2, position);
9988
+ if ((options.suppressBareHash ?? true) && shouldSuppressBareHashCompletion(linePrefix)) {
9989
+ return emptyCompletionResult(result);
9990
+ }
9991
+ if (!isCitationLabelCompletionContext(linePrefix)) {
9992
+ return result;
9993
+ }
9994
+ return mapCompletionItems(result, dedupeCitationCompletions);
9995
+ }
9996
+ function shouldSuppressBareHashCompletion(linePrefix) {
9997
+ return /(^|[^A-Za-z0-9_])#$/.test(linePrefix);
9998
+ }
9999
+ function isCitationLabelCompletionContext(linePrefix) {
10000
+ return /#cite\s*\([^)\n]*<[^>\s,;)\]]*$/.test(linePrefix);
10001
+ }
10002
+ function dedupeCitationCompletions(items) {
10003
+ const output = [];
10004
+ const seen = /* @__PURE__ */ new Map();
10005
+ for (const item of items) {
10006
+ const key = citationCompletionKey(item);
10007
+ if (!key) {
10008
+ output.push(item);
10009
+ continue;
10010
+ }
10011
+ const index = seen.get(key);
10012
+ if (index === void 0) {
10013
+ seen.set(key, output.length);
10014
+ output.push(item);
10015
+ continue;
10016
+ }
10017
+ if (citationCompletionScore(item, key) > citationCompletionScore(output[index], key)) {
10018
+ output[index] = item;
10019
+ }
10020
+ }
10021
+ return output;
10022
+ }
10023
+ function lineTextBeforePosition(document2, position) {
10024
+ try {
10025
+ return document2.getText({
10026
+ start: { line: position.line, character: 0 },
10027
+ end: position
10028
+ });
10029
+ } catch {
10030
+ return "";
10031
+ }
10032
+ }
10033
+ function mapCompletionItems(result, map) {
10034
+ if (Array.isArray(result)) {
10035
+ return map(result);
10036
+ }
10037
+ return {
10038
+ ...result,
10039
+ items: map(result.items)
10040
+ };
10041
+ }
10042
+ function emptyCompletionResult(result) {
10043
+ if (Array.isArray(result)) {
10044
+ return [];
10045
+ }
10046
+ return {
10047
+ ...result,
10048
+ isIncomplete: false,
10049
+ items: []
10050
+ };
10051
+ }
10052
+ function citationCompletionKey(item) {
10053
+ return normalizeCitationKey(completionInsertText(item)) ?? normalizeCitationKey(item.filterText) ?? normalizeCitationKey(item.label);
10054
+ }
10055
+ function completionInsertText(item) {
10056
+ const textEdit = item.textEdit;
10057
+ if (typeof textEdit?.newText === "string") {
10058
+ return textEdit.newText;
10059
+ }
10060
+ if (typeof item.textEditText === "string") {
10061
+ return item.textEditText;
10062
+ }
10063
+ if (typeof item.insertText === "string") {
10064
+ return item.insertText;
10065
+ }
10066
+ return item.label;
10067
+ }
10068
+ function normalizeCitationKey(value) {
10069
+ if (value === void 0) {
10070
+ return void 0;
10071
+ }
10072
+ let key = value.trim();
10073
+ if (key.startsWith("@")) {
10074
+ key = key.slice(1);
10075
+ }
10076
+ key = key.replace(/^<+/, "").replace(/>+$/, "");
10077
+ if (!key || /[\s()[\]{},"']/.test(key)) {
10078
+ return void 0;
10079
+ }
10080
+ return key;
10081
+ }
10082
+ function citationCompletionScore(item, key) {
10083
+ let score = 0;
10084
+ if (normalizeCitationKey(item.label) === key) {
10085
+ score += 100;
10086
+ }
10087
+ if (normalizeCitationKey(item.filterText) === key) {
10088
+ score += 30;
10089
+ }
10090
+ if (normalizeCitationKey(completionInsertText(item)) === key) {
10091
+ score += 20;
10092
+ }
10093
+ if (item.label.length <= key.length + 2) {
10094
+ score += 10;
10095
+ }
10096
+ return score;
10097
+ }
10098
+
10099
+ // src/client/index.ts
9972
10100
  function getWorkspaceRoot() {
9973
10101
  if (import_coc17.workspace.workspaceFolders.length) {
9974
10102
  return import_coc17.Uri.parse(import_coc17.workspace.workspaceFolders[0].uri).fsPath;
@@ -10080,6 +10208,12 @@ function createClient(bin, config2) {
10080
10208
  return Array.isArray(result) ? patchWorkspaceConfiguration(sections, result, getTinymistRuntimeConfig(config2)) : result;
10081
10209
  }
10082
10210
  },
10211
+ async provideCompletionItem(document2, position, completionContext, token, next) {
10212
+ const result = await next(document2, position, completionContext, token);
10213
+ return filterTinymistCompletions(document2, position, result, {
10214
+ suppressBareHash: config2.completionSuppressBareHash
10215
+ });
10216
+ },
10083
10217
  async provideCodeActions(document2, range, actionContext, token, next) {
10084
10218
  const params = {
10085
10219
  textDocument: { uri: document2.uri },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coc-tinymist",
3
- "version": "0.1.0",
3
+ "version": "0.1.75",
4
4
  "description": "Typst language support for coc.nvim powered by Tinymist",
5
5
  "author": "SeniorMars <cjh16@rice.edu>",
6
6
  "license": "MIT",
@@ -504,6 +504,11 @@
504
504
  "default": false,
505
505
  "markdownDescription": "Enable coc-tinymist's opt-in inlay hint fallback for simple local Typst function parameter names. This provider is additive to Tinymist's inlay hints."
506
506
  },
507
+ "tinymist.completion.suppressBareHash": {
508
+ "type": "boolean",
509
+ "default": true,
510
+ "markdownDescription": "Suppress Tinymist completions at a standalone bare `#`. Set to `false` to show Tinymist's full bare-`#` completion list."
511
+ },
507
512
  "tinymist.fallback.maxFileBytes": {
508
513
  "type": "number",
509
514
  "default": 524288,