coc-tinymist 0.1.0
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/LICENSE +21 -0
- package/README.md +222 -0
- package/lib/index.js +11533 -0
- package/package.json +838 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 SeniorMars
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# coc-tinymist
|
|
2
|
+
|
|
3
|
+
Typst language support for coc.nvim powered by [Tinymist](https://github.com/Myriad-Dreamin/tinymist).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```vim
|
|
8
|
+
:CocInstall coc-tinymist
|
|
9
|
+
```
|
|
10
|
+
|
|
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
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
|
|
15
|
+
Common settings in `coc-settings.json`:
|
|
16
|
+
|
|
17
|
+
```jsonc
|
|
18
|
+
{
|
|
19
|
+
"semanticTokens.enable": false,
|
|
20
|
+
"[typst]": {
|
|
21
|
+
"semanticTokens.enable": true
|
|
22
|
+
},
|
|
23
|
+
"tinymist.enable": true,
|
|
24
|
+
"tinymist.serverPath": null,
|
|
25
|
+
"tinymist.serverArgs": ["lsp"],
|
|
26
|
+
"tinymist.updates.mode": "prompt",
|
|
27
|
+
"tinymist.rootPath": null,
|
|
28
|
+
"tinymist.outputPath": "",
|
|
29
|
+
"tinymist.exportTarget": "paged",
|
|
30
|
+
"tinymist.formatterMode": "typstyle",
|
|
31
|
+
"tinymist.formatterPrintWidth": 120,
|
|
32
|
+
"tinymist.fontPaths": null,
|
|
33
|
+
"tinymist.systemFonts": true,
|
|
34
|
+
"tinymist.exportPdf": "never",
|
|
35
|
+
"tinymist.exportOnSave": [],
|
|
36
|
+
"tinymist.exportOnType": [],
|
|
37
|
+
"tinymist.exportOnIdle": [],
|
|
38
|
+
"tinymist.exportOpenAfterSave": false,
|
|
39
|
+
"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,
|
|
51
|
+
"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
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
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.
|
|
74
|
+
|
|
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`.
|
|
76
|
+
|
|
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.
|
|
78
|
+
|
|
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.
|
|
80
|
+
|
|
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.
|
|
82
|
+
|
|
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.
|
|
84
|
+
|
|
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`.
|
|
86
|
+
|
|
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.
|
|
88
|
+
|
|
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.
|
|
90
|
+
|
|
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.
|
|
92
|
+
|
|
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`.
|
|
94
|
+
|
|
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.
|
|
96
|
+
|
|
97
|
+
## Commands
|
|
98
|
+
|
|
99
|
+
Use these with `:CocCommand`:
|
|
100
|
+
|
|
101
|
+
| Command | Description |
|
|
102
|
+
| --- | --- |
|
|
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 |
|
|
155
|
+
|
|
156
|
+
## Lists
|
|
157
|
+
|
|
158
|
+
Use these with `:CocList`:
|
|
159
|
+
|
|
160
|
+
| List | Description |
|
|
161
|
+
| --- | --- |
|
|
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`.
|
|
167
|
+
|
|
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`.
|
|
169
|
+
|
|
170
|
+
## Troubleshooting
|
|
171
|
+
|
|
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.
|
|
173
|
+
|
|
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.
|
|
177
|
+
|
|
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.
|
|
179
|
+
|
|
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`.
|
|
181
|
+
|
|
182
|
+
If commands say Tinymist is not running, run `:CocCommand tinymist.showLog`, `:CocCommand tinymist.showStatus`, and `:CocCommand tinymist.doctor`. Then try `:CocCommand tinymist.restartServer`.
|
|
183
|
+
|
|
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.
|
|
185
|
+
|
|
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.
|
|
187
|
+
|
|
188
|
+
The on-enter keymap is disabled by default. Set `"tinymist.onEnterEvent": true` to enable it.
|
|
189
|
+
|
|
190
|
+
## Development QA
|
|
191
|
+
|
|
192
|
+
Run these before publishing:
|
|
193
|
+
|
|
194
|
+
```sh
|
|
195
|
+
npm run typecheck
|
|
196
|
+
npm test
|
|
197
|
+
npm run qa:commands
|
|
198
|
+
npm run qa:coc
|
|
199
|
+
npm run qa:lsp
|
|
200
|
+
npm pack --dry-run
|
|
201
|
+
```
|
|
202
|
+
|
|
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.
|
|
204
|
+
|
|
205
|
+
For a manual release smoke, open `fixtures/sample.typ` in Neovim with Coc enabled and verify:
|
|
206
|
+
|
|
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
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
MIT
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
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).
|