coc-vscode-loader 1.2.4 → 1.2.6

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 CHANGED
@@ -37,8 +37,9 @@ npm install coc-vscode-loader
37
37
  | `x` | Toggle mark package for batch operations |
38
38
  | `f` | Cycle filter: all → installed → available |
39
39
  | `s` | Cycle sort: default → name → status → type |
40
- | `gg` | Jump to first package |
41
- | `G` | Jump to last package |
40
+ | `[` / `]` | Previous / next page |
41
+ | `gg` | Jump to first page |
42
+ | `G` | Jump to last page |
42
43
  | `<CR>` | Toggle details (commit / type / source) or install log |
43
44
  | `/` | Search filter |
44
45
  | `q` | Close (auto `:CocRestart` if changes detected) |
@@ -60,6 +61,7 @@ npm install coc-vscode-loader
60
61
 
61
62
  - **Real conversion pipeline** — git clone → converter → npm install → esbuild → register to coc
62
63
  - **Auto-fetch registry** — remote registry fetched in background when TUI opens, no manual refresh needed
64
+ - **Pagination** — `[`/`]` prev/next page, 50 packages per page, handles 5000+ registry entries
63
65
  - **Incremental cache** — source/ keeps git repo, updates via git pull only
64
66
  - **Commit tracking** — records commit SHA after install, visible in detail view
65
67
  - **Update check** — `C` key compares against remote HEAD, shows `↑` when outdated
Binary file
@@ -0,0 +1,151 @@
1
+ # converter — vscode → coc converter prototype
2
+
3
+ CLI tool that automatically converts VS Code extensions to coc.nvim plugins.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ # Create a convert config (describe how to transform the plugin)
9
+ echo '[{"type":"source","transforms":["import-mapping"],"entry":"src/extension.ts"}]' > convert.json
10
+
11
+ # Convert a VS Code extension directory
12
+ npx tsx src/cli.ts convert ./vscode-ext/ -o ./coc-ext/ --convert-file convert.json
13
+
14
+ # Build and install to coc
15
+ cd ./coc-ext && npm install && node esbuild.mjs
16
+ cd ~/.config/coc/extensions && npm install /path/to/coc-ext
17
+ ```
18
+
19
+ ## Verified conversions
20
+
21
+ | Plugin | Type | Notes |
22
+ |--------|------|-------|
23
+ | Volar (Vue) | TS bridge | Requires modified coc-tsserver |
24
+ | Prisma | Pure LSP | Auto-detects bin entry |
25
+ | HTML CSS Support | Direct API | Handles API differences |
26
+ | Deno | Pure LSP | Binary server download |
27
+ | TOML (Taplo) | Pure LSP | Binary server download |
28
+ | Ansible | Pure LSP | npm package server + pip install |
29
+ | YAML | Pure LSP | npm package server |
30
+ | Tailwind CSS | Pure LSP | npm package server, bin entry |
31
+ | Biome | Pure LSP | Binary server download |
32
+ | Stylelint | Pure LSP | npm package server |
33
+ | Prettier | Direct API | Source transforms |
34
+ | Svelte | Pure LSP | npm package server |
35
+ | Astro | Pure LSP | npm package server |
36
+ | Lua | Pure LSP | npm package server |
37
+ | gitignore | Direct API | Source transforms |
38
+
39
+ See the [registry](https://github.com/coc-plugin/coc-vscode-registry) for the full list and latest status.
40
+
41
+ ### Plugin types
42
+
43
+ | Type | Description | Approach | Example |
44
+ |------|-------------|----------|---------|
45
+ | **TS bridge** | Language plugins depending on TypeScript LSP | Generate `tsserver/request` bridge + `typescriptServerPlugins` | Volar |
46
+ | **Pure LSP** | Standard LSP using LanguageClient | Generate LanguageClient entry + server dependency injection | Prisma |
47
+ | **Direct API** | Direct coc.nvim API calls (no LanguageClient) | Keep original `extension.ts` as entry, no bridge | HTML CSS Support |
48
+
49
+ TS bridge plugins require a modified coc-tsserver ([PR #493](https://github.com/neoclide/coc-tsserver/pull/493)):
50
+
51
+ ```bash
52
+ cd ~/.config/coc/extensions
53
+ npm install ChuYanLon/coc-tsserver --legacy-peer-deps
54
+ ```
55
+
56
+ ## Architecture
57
+
58
+ ```
59
+ Input: VS Code extension directory
60
+
61
+ ├─ scanner Analyze API → detect plugin type
62
+ ├─ transforms/ AST transforms
63
+ │ ├─ import-mapping from 'vscode' → from 'coc.nvim'
64
+ │ ├─ class-to-factory new Xxx() → Xxx.create()
65
+ │ ├─ provider-register Adapt provider registration signatures
66
+ │ ├─ language-client Adapt LanguageClient signatures
67
+ │ └─ enum-offset Comment on enum value offsets
68
+ ├─ mark-unsupported Replace/mark missing APIs (getWordRangeAtPosition, fileName, etc.)
69
+ ├─ generate src/index.ts Main entry (bridge / LanguageClient / direct templates)
70
+ ├─ generate package.json Dependencies / esbuild external config
71
+ └─ generate esbuild.mjs Build config
72
+ ```
73
+
74
+ ## Bridge preset system
75
+
76
+ Bridge logic is preset-driven rather than hardcoded:
77
+
78
+ ```typescript
79
+ // presets.ts - all bridge presets defined here
80
+ const PRESETS = {
81
+ 'ts-bridge': {
82
+ notification: 'tsserver/request',
83
+ responseNotification: 'tsserver/response',
84
+ handler: { type: 'command', command: 'typescript.tsserverRequest' },
85
+ extraDeps: ['typescript'],
86
+ },
87
+ // future: python-bridge, rust-bridge, etc.
88
+ }
89
+ ```
90
+
91
+ `convert.ts` only calls `getActivePresets()` + `generateBridgeCode()`, it never touches bridge logic directly.
92
+ Adding a new bridge type = add a new preset in `presets.ts`, no changes to main flow.
93
+
94
+ See [../docs/converter-design-v2.md](../docs/converter-design-v2.md).
95
+
96
+ ## File structure
97
+
98
+ | File | Lines | Description |
99
+ |------|-------|-------------|
100
+ | `src/cli.ts` | 59 | CLI entry |
101
+ | `src/convert.ts` | 461 | Main flow + template generation + API replacement |
102
+ | `src/scanner.ts` | 52 | API scanner + plugin classification |
103
+ | `src/transforms/import-mapping.ts` | 193 | Import replacement |
104
+ | `src/transforms/language-client.ts` | 48 | LanguageClient adaptation |
105
+ | `src/transforms/class-to-factory.ts` | 53 | new Xxx() → Xxx.create() |
106
+ | `src/transforms/provider-register.ts` | 61 | Provider registration signature fixes |
107
+ | `src/transforms/enum-offset.ts` | 32 | Enum value offset annotations |
108
+ | **Total** | **~959** | |
109
+
110
+ ## Handled API differences
111
+
112
+ | API | VS Code | coc.nvim | Handling |
113
+ |-----|---------|----------|----------|
114
+ | import | `from 'vscode'` | `from 'coc.nvim'` | Direct replace |
115
+ | Position/Range/Location etc. | `new Xxx()` | `Xxx.create()` | AST replace |
116
+ | EventEmitter | `EventEmitter<T>` | `Emitter<T>` | Direct replace |
117
+ | registerCompletionItemProvider | `(sel, p, ...t)` | `(name, shortcut, sel, p, t?)` | Pad arguments |
118
+ | registerCodeActionsProvider | `registerCodeActionsProvider` | `registerCodeActionProvider` | Rename |
119
+ | registerReferenceProvider | `registerReferenceProvider` | `registerReferencesProvider` | Rename |
120
+ | CompletionItem.create | `new CompletionItem(label, kind)` | `CompletionItem.create(label)` + `item.kind = kind` | kind set separately |
121
+ | Trigger characters | `" "` (string) | `[" "]` (array) | Rest param → array |
122
+ | CompletionItemKind enum | `Value = 11`, `Enum = 12` | `Value = 12`, `Enum = 13` | Offset by 1, symbols auto-adapt |
123
+ | documentSelector | `[{ language: 'xxx' }]` | Same | Auto-infer from package.json |
124
+ | getWordRangeAtPosition | `document.getWordRangeAtPosition()` | Not available | Inline word boundary calculation |
125
+ | fileName | `document.fileName` | Not available | Replace with `document.uri` |
126
+ | createTextEditorDecorationType | `window.createTextEditorDecorationType()` | Not available | Mark TODO |
127
+ | createWebviewPanel | `window.createWebviewPanel()` | Not available | Mark TODO |
128
+
129
+ ### Missing API strategy
130
+
131
+ When a VS Code API has no coc.nvim equivalent, the approach is:
132
+
133
+ 1. Find the [VS Code source](https://github.com/microsoft/vscode) implementation
134
+ 2. Evaluate complexity:
135
+ - **Simple** (e.g. `getWordRangeAtPosition`) → inline polyfill
136
+ - **Complex** (e.g. decoration, webview) → mark TODO with explanation
137
+ 3. Polyfill using existing coc APIs where possible, avoid new dependencies
138
+
139
+ Known VS Code API source locations:
140
+ - `getWordRangeAtPosition` → `src/vs/editor/common/core/wordHelper.ts`
141
+ - `TextDocument.fileName` → coc uses `document.uri` instead (`DocumentUri = string`)
142
+ - Decoration system → `src/vs/editor/common/viewModel/viewDecorations.ts`
143
+
144
+ ## Key design decisions
145
+
146
+ - **Zero hardcoding** — server package names auto-detected from source
147
+ - **Bin entry fallback** — auto-detect and prefer `package.json` bin entry
148
+ - **Auto esbuild external injection** — detected server packages marked as external
149
+ - **Auto TS bridge injection** — `typescriptServerPlugins` + `tsserver/request` forwarding
150
+ - **Plugin classification** — auto-detect TS bridge / pure LSP / direct API
151
+ - **Missing API handling** — polyfill where possible, mark TODO otherwise