coc-tinymist 0.1.0 → 0.1.5
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.
- package/README.md +239 -142
- package/lib/index.js +114 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# coc-tinymist
|
|
2
2
|
|
|
3
|
-
Typst language support for coc.nvim
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
"tinymist.rootPath": null,
|
|
28
|
-
"tinymist.outputPath": "",
|
|
29
|
-
"tinymist.exportTarget": "paged",
|
|
58
|
+
|
|
30
59
|
"tinymist.formatterMode": "typstyle",
|
|
31
60
|
"tinymist.formatterPrintWidth": 120,
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
145
|
+
```jsonc
|
|
146
|
+
{
|
|
147
|
+
"tinymist.outputPath": "build/{relativeDir}/{name}-{page}.{ext}"
|
|
148
|
+
}
|
|
149
|
+
```
|
|
76
150
|
|
|
77
|
-
|
|
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
|
-
|
|
153
|
+
### Markdown Trust
|
|
80
154
|
|
|
81
|
-
|
|
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
|
-
|
|
160
|
+
## Commands
|
|
84
161
|
|
|
85
|
-
|
|
162
|
+
Run commands with `:CocCommand`.
|
|
86
163
|
|
|
87
|
-
|
|
164
|
+
### Server and Config
|
|
88
165
|
|
|
89
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
216
|
+
### Templates
|
|
96
217
|
|
|
97
|
-
|
|
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
|
-
|
|
226
|
+
### Tasks and Diagnostics
|
|
100
227
|
|
|
101
228
|
| Command | Description |
|
|
102
229
|
| --- | --- |
|
|
103
|
-
| `tinymist.
|
|
104
|
-
| `tinymist.
|
|
105
|
-
| `tinymist.
|
|
106
|
-
| `tinymist.
|
|
107
|
-
| `tinymist.
|
|
108
|
-
| `tinymist.
|
|
109
|
-
| `tinymist.
|
|
110
|
-
| `tinymist.
|
|
111
|
-
| `tinymist.
|
|
112
|
-
| `tinymist.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
255
|
+
Start with:
|
|
173
256
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
257
|
+
```vim
|
|
258
|
+
:CocCommand tinymist.doctor
|
|
259
|
+
```
|
|
177
260
|
|
|
178
|
-
|
|
261
|
+
For issue reports, prefer:
|
|
179
262
|
|
|
180
|
-
|
|
263
|
+
```vim
|
|
264
|
+
:CocCommand tinymist.doctorCopyIssueTemplate
|
|
265
|
+
```
|
|
181
266
|
|
|
182
|
-
|
|
267
|
+
The copied report redacts proxy credentials, token-like environment keys and values, and configured paths where possible.
|
|
183
268
|
|
|
184
|
-
|
|
269
|
+
Common fixes:
|
|
185
270
|
|
|
186
|
-
|
|
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
|
-
|
|
279
|
+
File-sensitive commands such as export, test, profile, template insertion, and pin-current-main require a file-backed Typst buffer.
|
|
189
280
|
|
|
190
|
-
|
|
281
|
+
VS Code-only Tinymist settings such as webview preview, drag/drop, and paste handling are intentionally omitted.
|
|
191
282
|
|
|
192
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
@@ -9969,6 +9969,116 @@ var BinaryResolver = class {
|
|
|
9969
9969
|
|
|
9970
9970
|
// src/client/index.ts
|
|
9971
9971
|
var import_coc17 = require("coc.nvim");
|
|
9972
|
+
|
|
9973
|
+
// src/features/completion.ts
|
|
9974
|
+
function filterTinymistCompletions(document2, position, context, result) {
|
|
9975
|
+
if (!result) {
|
|
9976
|
+
return result;
|
|
9977
|
+
}
|
|
9978
|
+
const linePrefix = lineTextBeforePosition(document2, position);
|
|
9979
|
+
if (shouldSuppressBareHashCompletion(linePrefix, context)) {
|
|
9980
|
+
return mapCompletionItems(result, () => []);
|
|
9981
|
+
}
|
|
9982
|
+
if (!isCitationLabelCompletionContext(linePrefix)) {
|
|
9983
|
+
return result;
|
|
9984
|
+
}
|
|
9985
|
+
return mapCompletionItems(result, dedupeCitationCompletions);
|
|
9986
|
+
}
|
|
9987
|
+
function shouldSuppressBareHashCompletion(linePrefix, context) {
|
|
9988
|
+
const isTriggerCompletion = context?.triggerCharacter === "#" || context?.triggerKind === 2;
|
|
9989
|
+
return Boolean(isTriggerCompletion && /(^|[^A-Za-z0-9_])#$/.test(linePrefix));
|
|
9990
|
+
}
|
|
9991
|
+
function isCitationLabelCompletionContext(linePrefix) {
|
|
9992
|
+
return /#cite\s*\([^)\n]*<[^>\s,;)\]]*$/.test(linePrefix);
|
|
9993
|
+
}
|
|
9994
|
+
function dedupeCitationCompletions(items) {
|
|
9995
|
+
const output = [];
|
|
9996
|
+
const seen = /* @__PURE__ */ new Map();
|
|
9997
|
+
for (const item of items) {
|
|
9998
|
+
const key = citationCompletionKey(item);
|
|
9999
|
+
if (!key) {
|
|
10000
|
+
output.push(item);
|
|
10001
|
+
continue;
|
|
10002
|
+
}
|
|
10003
|
+
const index = seen.get(key);
|
|
10004
|
+
if (index === void 0) {
|
|
10005
|
+
seen.set(key, output.length);
|
|
10006
|
+
output.push(item);
|
|
10007
|
+
continue;
|
|
10008
|
+
}
|
|
10009
|
+
if (citationCompletionScore(item, key) > citationCompletionScore(output[index], key)) {
|
|
10010
|
+
output[index] = item;
|
|
10011
|
+
}
|
|
10012
|
+
}
|
|
10013
|
+
return output;
|
|
10014
|
+
}
|
|
10015
|
+
function lineTextBeforePosition(document2, position) {
|
|
10016
|
+
try {
|
|
10017
|
+
return document2.getText({
|
|
10018
|
+
start: { line: position.line, character: 0 },
|
|
10019
|
+
end: position
|
|
10020
|
+
});
|
|
10021
|
+
} catch {
|
|
10022
|
+
return "";
|
|
10023
|
+
}
|
|
10024
|
+
}
|
|
10025
|
+
function mapCompletionItems(result, map) {
|
|
10026
|
+
if (Array.isArray(result)) {
|
|
10027
|
+
return map(result);
|
|
10028
|
+
}
|
|
10029
|
+
return {
|
|
10030
|
+
...result,
|
|
10031
|
+
items: map(result.items)
|
|
10032
|
+
};
|
|
10033
|
+
}
|
|
10034
|
+
function citationCompletionKey(item) {
|
|
10035
|
+
return normalizeCitationKey(completionInsertText(item)) ?? normalizeCitationKey(item.filterText) ?? normalizeCitationKey(item.label);
|
|
10036
|
+
}
|
|
10037
|
+
function completionInsertText(item) {
|
|
10038
|
+
const textEdit = item.textEdit;
|
|
10039
|
+
if (typeof textEdit?.newText === "string") {
|
|
10040
|
+
return textEdit.newText;
|
|
10041
|
+
}
|
|
10042
|
+
if (typeof item.textEditText === "string") {
|
|
10043
|
+
return item.textEditText;
|
|
10044
|
+
}
|
|
10045
|
+
if (typeof item.insertText === "string") {
|
|
10046
|
+
return item.insertText;
|
|
10047
|
+
}
|
|
10048
|
+
return item.label;
|
|
10049
|
+
}
|
|
10050
|
+
function normalizeCitationKey(value) {
|
|
10051
|
+
if (value === void 0) {
|
|
10052
|
+
return void 0;
|
|
10053
|
+
}
|
|
10054
|
+
let key = value.trim();
|
|
10055
|
+
if (key.startsWith("@")) {
|
|
10056
|
+
key = key.slice(1);
|
|
10057
|
+
}
|
|
10058
|
+
key = key.replace(/^<+/, "").replace(/>+$/, "");
|
|
10059
|
+
if (!key || /[\s()[\]{},"']/.test(key)) {
|
|
10060
|
+
return void 0;
|
|
10061
|
+
}
|
|
10062
|
+
return key;
|
|
10063
|
+
}
|
|
10064
|
+
function citationCompletionScore(item, key) {
|
|
10065
|
+
let score = 0;
|
|
10066
|
+
if (normalizeCitationKey(item.label) === key) {
|
|
10067
|
+
score += 100;
|
|
10068
|
+
}
|
|
10069
|
+
if (normalizeCitationKey(item.filterText) === key) {
|
|
10070
|
+
score += 30;
|
|
10071
|
+
}
|
|
10072
|
+
if (normalizeCitationKey(completionInsertText(item)) === key) {
|
|
10073
|
+
score += 20;
|
|
10074
|
+
}
|
|
10075
|
+
if (item.label.length <= key.length + 2) {
|
|
10076
|
+
score += 10;
|
|
10077
|
+
}
|
|
10078
|
+
return score;
|
|
10079
|
+
}
|
|
10080
|
+
|
|
10081
|
+
// src/client/index.ts
|
|
9972
10082
|
function getWorkspaceRoot() {
|
|
9973
10083
|
if (import_coc17.workspace.workspaceFolders.length) {
|
|
9974
10084
|
return import_coc17.Uri.parse(import_coc17.workspace.workspaceFolders[0].uri).fsPath;
|
|
@@ -10080,6 +10190,10 @@ function createClient(bin, config2) {
|
|
|
10080
10190
|
return Array.isArray(result) ? patchWorkspaceConfiguration(sections, result, getTinymistRuntimeConfig(config2)) : result;
|
|
10081
10191
|
}
|
|
10082
10192
|
},
|
|
10193
|
+
async provideCompletionItem(document2, position, completionContext, token, next) {
|
|
10194
|
+
const result = await next(document2, position, completionContext, token);
|
|
10195
|
+
return filterTinymistCompletions(document2, position, completionContext, result);
|
|
10196
|
+
},
|
|
10083
10197
|
async provideCodeActions(document2, range, actionContext, token, next) {
|
|
10084
10198
|
const params = {
|
|
10085
10199
|
textDocument: { uri: document2.uri },
|