opencode-vim 0.0.22 → 0.0.24
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 +25 -63
- package/assets/vim-in-motion-dialogs.gif +0 -0
- package/dist/tui.js +3326 -0
- package/docs/configuration.md +50 -400
- package/docs/keymap-actions.md +60 -188
- package/docs/vim-behavior.md +93 -0
- package/package.json +6 -6
- package/src/modules/snippets/index.tsx +0 -17
- package/src/modules/snippets/loader.ts +0 -147
- package/src/modules/snippets/search.ts +0 -118
- package/src/modules/snippets/skill-loader.ts +0 -81
- package/src/modules/snippets/state.ts +0 -40
- package/src/modules/snippets/trigger.ts +0 -68
- package/src/modules/snippets/types.ts +0 -50
- package/src/modules/snippets/view.tsx +0 -674
- package/src/modules/vim/actions.ts +0 -85
- package/src/modules/vim/config.ts +0 -125
- package/src/modules/vim/edit.test.ts +0 -51
- package/src/modules/vim/edit.ts +0 -33
- package/src/modules/vim/graphemes.ts +0 -38
- package/src/modules/vim/index.tsx +0 -200
- package/src/modules/vim/keys.ts +0 -38
- package/src/modules/vim/log.ts +0 -37
- package/src/modules/vim/map.test.ts +0 -45
- package/src/modules/vim/map.ts +0 -198
- package/src/modules/vim/state.test.ts +0 -18
- package/src/modules/vim/state.tsx +0 -46
- package/src/modules/vim/view.tsx +0 -130
- package/src/modules/vim/vimee.test.ts +0 -211
- package/src/modules/vim/vimee.ts +0 -1146
- package/src/plugin.tsx +0 -116
- package/src/prompt/host.tsx +0 -38
- package/src/prompt/modules.ts +0 -16
- package/src/prompt/root.tsx +0 -69
- package/src/prompt/types.ts +0 -42
- package/src/update.ts +0 -120
- package/tui.tsx +0 -275
- package/view.tsx +0 -29
package/docs/configuration.md
CHANGED
|
@@ -1,431 +1,81 @@
|
|
|
1
|
-
# Configuration
|
|
1
|
+
# Configuration
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Replace the plugin entry in `cli.json` with an object containing `options.vim`.
|
|
4
|
+
This example uses `Q` for session mode and `kj` to leave insert mode:
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Add `opencode-vim` to the `plugin` array in your OpenCode `tui.jsonc` file:
|
|
8
|
-
|
|
9
|
-
```jsonc
|
|
10
|
-
{
|
|
11
|
-
"$schema": "https://opencode.ai/tui.json",
|
|
12
|
-
"plugin": [
|
|
13
|
-
[
|
|
14
|
-
"./plugin/opencode-vim",
|
|
15
|
-
{
|
|
16
|
-
"autoUpdate": true,
|
|
17
|
-
"vim": {
|
|
18
|
-
"defaultMode": "insert"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
If your plugin is installed somewhere else, change the plugin path to match your setup.
|
|
27
|
-
|
|
28
|
-
## Full Example
|
|
29
|
-
|
|
30
|
-
```jsonc
|
|
6
|
+
```json
|
|
31
7
|
{
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
{
|
|
37
|
-
"autoUpdate": true,
|
|
8
|
+
"plugins": [
|
|
9
|
+
{
|
|
10
|
+
"package": "opencode-vim@latest",
|
|
11
|
+
"options": {
|
|
38
12
|
"vim": {
|
|
39
|
-
"
|
|
40
|
-
"keymapTimeout": 500,
|
|
41
|
-
"pendingDisplayDelay": 120,
|
|
42
|
-
"cursorStyles": {
|
|
43
|
-
"insert": {
|
|
44
|
-
"style": "line",
|
|
45
|
-
"blinking": true
|
|
46
|
-
},
|
|
47
|
-
"normal": {
|
|
48
|
-
"style": "block",
|
|
49
|
-
"blinking": true
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"debug": false,
|
|
53
|
-
"debugPath": "/home/you/.cache/opencode/opencode-vim.log",
|
|
13
|
+
"sessionKey": "Q",
|
|
54
14
|
"keymaps": {
|
|
55
|
-
"insert": {
|
|
56
|
-
"kj": "normal"
|
|
57
|
-
},
|
|
58
|
-
"normal": {
|
|
59
|
-
"<CR>": "submit",
|
|
60
|
-
"Y": "y$"
|
|
61
|
-
}
|
|
15
|
+
"insert": { "kj": "normal" }
|
|
62
16
|
}
|
|
63
17
|
}
|
|
64
18
|
}
|
|
65
|
-
|
|
19
|
+
}
|
|
66
20
|
]
|
|
67
21
|
}
|
|
68
22
|
```
|
|
69
23
|
|
|
70
24
|
## Options
|
|
71
25
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Updates `opencode-vim` automatically when a newer npm version is available.
|
|
75
|
-
|
|
76
|
-
Default:
|
|
77
|
-
|
|
78
|
-
```jsonc
|
|
79
|
-
"autoUpdate": true
|
|
80
|
-
```
|
|
26
|
+
All options below belong inside `options.vim`.
|
|
81
27
|
|
|
82
|
-
|
|
28
|
+
| Option | Default | Purpose |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| `defaultMode` | `"insert"` | Starting Vim mode; use `"normal"` to start in normal mode |
|
|
31
|
+
| `sessionKey` | `"s"` | Single key to enter and leave session mode |
|
|
32
|
+
| `keymapTimeout` | `500` | Milliseconds to wait for the rest of a custom mapping |
|
|
33
|
+
| `keymaps` | `{}` | Prompt and search-dialog mappings, grouped by mode |
|
|
34
|
+
| `cursorStyles` | See below | Cursor appearance for each editing mode |
|
|
35
|
+
| `debug` | `false` | Enable debug logging |
|
|
36
|
+
| `debugPath` | `~/.cache/opencode/opencode-vim.log` | Debug log file |
|
|
83
37
|
|
|
84
|
-
|
|
85
|
-
"autoUpdate": false
|
|
86
|
-
```
|
|
38
|
+
### Session key
|
|
87
39
|
|
|
88
|
-
|
|
40
|
+
Use one character, such as `"Q"`, or key notation such as `"<C-s>"`. The key changes
|
|
41
|
+
both entry and exit, including the footer hints. Invalid or multi-key values fall
|
|
42
|
+
back to `"s"`.
|
|
89
43
|
|
|
90
|
-
|
|
44
|
+
A custom normal-mode mapping beginning with the same key takes precedence over
|
|
45
|
+
entering session mode.
|
|
91
46
|
|
|
92
|
-
|
|
47
|
+
### Custom keymaps
|
|
93
48
|
|
|
94
|
-
|
|
95
|
-
-
|
|
49
|
+
Mappings apply to `insert`, `normal`, `visual`, and `visual-line` editing modes in
|
|
50
|
+
the prompt and search dialogs. Session browsing and its read-only modal use their
|
|
51
|
+
own bindings.
|
|
96
52
|
|
|
97
|
-
|
|
53
|
+
See [Custom Keymaps](./keymap-actions.md) for actions, key notation, and examples.
|
|
54
|
+
See [Keybindings and Modes](./vim-behavior.md) for the default behavior.
|
|
98
55
|
|
|
99
|
-
|
|
100
|
-
"defaultMode": "insert"
|
|
101
|
-
```
|
|
56
|
+
### Cursor styles
|
|
102
57
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
"defaultMode": "normal"
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### `keymapTimeout`
|
|
110
|
-
|
|
111
|
-
How long, in milliseconds, the prompt waits for the next key when a configured keymap has only been partially typed.
|
|
112
|
-
|
|
113
|
-
Default:
|
|
114
|
-
|
|
115
|
-
```jsonc
|
|
116
|
-
"keymapTimeout": 500
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Examples:
|
|
120
|
-
|
|
121
|
-
```jsonc
|
|
122
|
-
"keymapTimeout": 250
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
```jsonc
|
|
126
|
-
"keymapTimeout": 1000
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
Use a shorter timeout for faster fallback after partial mappings. Use a longer timeout if you type multi-key mappings slowly.
|
|
130
|
-
|
|
131
|
-
### `pendingDisplayDelay`
|
|
132
|
-
|
|
133
|
-
How long, in milliseconds, the prompt waits before showing a pending key sequence in the status area.
|
|
134
|
-
|
|
135
|
-
Default:
|
|
136
|
-
|
|
137
|
-
```jsonc
|
|
138
|
-
"pendingDisplayDelay": 120
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Examples:
|
|
142
|
-
|
|
143
|
-
```jsonc
|
|
144
|
-
"pendingDisplayDelay": 0
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
```jsonc
|
|
148
|
-
"pendingDisplayDelay": 300
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
This only affects display. It does not change how long keymaps wait for more input.
|
|
152
|
-
|
|
153
|
-
### `cursorStyles`
|
|
154
|
-
|
|
155
|
-
The cursor style to use in each mode.
|
|
156
|
-
|
|
157
|
-
Allowed styles:
|
|
158
|
-
|
|
159
|
-
- `"block"`
|
|
160
|
-
- `"line"`
|
|
161
|
-
- `"underline"`
|
|
162
|
-
- `"default"`
|
|
163
|
-
|
|
164
|
-
Default:
|
|
165
|
-
|
|
166
|
-
```jsonc
|
|
167
|
-
"cursorStyles": {
|
|
168
|
-
"insert": {
|
|
169
|
-
"style": "line",
|
|
170
|
-
"blinking": true
|
|
171
|
-
},
|
|
172
|
-
"normal": {
|
|
173
|
-
"style": "block",
|
|
174
|
-
"blinking": true
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
Examples:
|
|
180
|
-
|
|
181
|
-
```jsonc
|
|
182
|
-
"cursorStyles": {
|
|
183
|
-
"insert": {
|
|
184
|
-
"style": "line",
|
|
185
|
-
"blinking": false
|
|
186
|
-
},
|
|
187
|
-
"normal": {
|
|
188
|
-
"style": "block",
|
|
189
|
-
"blinking": false
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
```jsonc
|
|
195
|
-
"cursorStyles": {
|
|
196
|
-
"insert": {
|
|
197
|
-
"style": "underline"
|
|
198
|
-
},
|
|
199
|
-
"normal": {
|
|
200
|
-
"style": "default"
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
You can configure only one mode if you want. Any omitted values use the defaults.
|
|
206
|
-
|
|
207
|
-
### `debug`
|
|
208
|
-
|
|
209
|
-
Enables debug logging.
|
|
210
|
-
|
|
211
|
-
Default:
|
|
212
|
-
|
|
213
|
-
```jsonc
|
|
214
|
-
"debug": false
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
Example:
|
|
218
|
-
|
|
219
|
-
```jsonc
|
|
220
|
-
"debug": true
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
You can also enable debug logging with this environment variable:
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
VIM_PROMPT_DEBUG=1
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### `debugPath`
|
|
230
|
-
|
|
231
|
-
The file path used for debug logs when debug logging is enabled.
|
|
232
|
-
|
|
233
|
-
Default:
|
|
234
|
-
|
|
235
|
-
```txt
|
|
236
|
-
~/.cache/opencode/opencode-vim.log
|
|
237
|
-
```
|
|
58
|
+
Insert mode defaults to a blinking line cursor. Normal, visual, and visual-line
|
|
59
|
+
modes default to a blinking block. Supported styles are `block`, `line`,
|
|
60
|
+
`underline`, and `default`. Omitted values keep their defaults.
|
|
238
61
|
|
|
239
|
-
|
|
62
|
+
For example, add this inside `options.vim` to disable cursor blinking:
|
|
240
63
|
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
### `keymaps`
|
|
248
|
-
|
|
249
|
-
Custom keymaps for each Vim mode.
|
|
250
|
-
|
|
251
|
-
Allowed modes:
|
|
252
|
-
|
|
253
|
-
- `"insert"`
|
|
254
|
-
- `"normal"`
|
|
255
|
-
- `"visual"`
|
|
256
|
-
- `"visual-line"`
|
|
257
|
-
|
|
258
|
-
Each keymap entry maps a key sequence to an action:
|
|
259
|
-
|
|
260
|
-
```jsonc
|
|
261
|
-
"keymaps": {
|
|
262
|
-
"insert": {
|
|
263
|
-
"kj": "normal"
|
|
264
|
-
},
|
|
265
|
-
"normal": {
|
|
266
|
-
"<CR>": "submit"
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
Supported built-in actions:
|
|
272
|
-
|
|
273
|
-
- `"normal"` exits insert mode and enters normal mode.
|
|
274
|
-
- `"insert"` enters insert mode.
|
|
275
|
-
- `"submit"` submits the OpenCode prompt.
|
|
276
|
-
|
|
277
|
-
Use `"command:<name>"` to dispatch an active OpenCode command. See [Keymap Actions](./keymap-actions.md) for the full action and command reference.
|
|
278
|
-
|
|
279
|
-
Any other action string is treated as a Vim key sequence. For example, this maps `Y` to yank from the cursor to the end of the line:
|
|
280
|
-
|
|
281
|
-
```jsonc
|
|
282
|
-
"keymaps": {
|
|
283
|
-
"normal": {
|
|
284
|
-
"Y": "y$"
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
Unlike other keys, `<CR>` in normal mode defaults to `"submit"` when no mapping is configured. A mode-specific mapping overrides that default. In insert mode, an unmapped `<CR>` passes through to OpenCode's `input_submit` and `input_newline` keybinds.
|
|
290
|
-
|
|
291
|
-
When `input_submit` is not `"return"`, map `input_newline` to `"return"` for insert-mode newlines.
|
|
292
|
-
|
|
293
|
-
## Keymap Syntax
|
|
294
|
-
|
|
295
|
-
Key sequences can contain printable ASCII characters, except literal spaces. Use `<Space>` for the space key.
|
|
296
|
-
|
|
297
|
-
Examples:
|
|
298
|
-
|
|
299
|
-
```jsonc
|
|
300
|
-
"x": "d"
|
|
301
|
-
"gg": "0"
|
|
302
|
-
"Y": "y$"
|
|
303
|
-
"\\r": "<C-r>"
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
Supported special keys:
|
|
307
|
-
|
|
308
|
-
- `<Esc>`
|
|
309
|
-
- `<CR>`
|
|
310
|
-
- `<Tab>`
|
|
311
|
-
- `<BS>`
|
|
312
|
-
- `<Del>`
|
|
313
|
-
- `<Space>`
|
|
314
|
-
- `<C-a>` through `<C-z>`
|
|
315
|
-
|
|
316
|
-
Ctrl key names must be lowercase. Use `<C-s>`, not `<C-S>`.
|
|
317
|
-
|
|
318
|
-
`<CR>` can be mapped directly or end a sequence, but cannot start a multi-key sequence.
|
|
319
|
-
|
|
320
|
-
Unsupported examples:
|
|
321
|
-
|
|
322
|
-
```jsonc
|
|
323
|
-
"<C-S>": "submit"
|
|
324
|
-
"<C-1>": "submit"
|
|
325
|
-
"<Up>": "k"
|
|
326
|
-
"a b": "normal"
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
Invalid keymaps are skipped. Enable debug logging if you need to troubleshoot keymap registration.
|
|
330
|
-
|
|
331
|
-
## Keymap Examples
|
|
332
|
-
|
|
333
|
-
Use `kj` or `jk` to leave insert mode:
|
|
334
|
-
|
|
335
|
-
```jsonc
|
|
336
|
-
"keymaps": {
|
|
337
|
-
"insert": {
|
|
338
|
-
"kj": "normal",
|
|
339
|
-
"jk": "normal"
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
Submit with `<CR>` in normal mode is the default, so this keymap is optional:
|
|
345
|
-
|
|
346
|
-
```jsonc
|
|
347
|
-
"keymaps": {
|
|
348
|
-
"normal": {
|
|
349
|
-
"<CR>": "submit"
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
Submit the prompt with Ctrl-S in insert mode:
|
|
355
|
-
|
|
356
|
-
```jsonc
|
|
357
|
-
"keymaps": {
|
|
358
|
-
"insert": {
|
|
359
|
-
"<C-s>": "submit"
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
Make `Y` yank to the end of the line:
|
|
365
|
-
|
|
366
|
-
```jsonc
|
|
367
|
-
"keymaps": {
|
|
368
|
-
"normal": {
|
|
369
|
-
"Y": "y$"
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
Make `D` delete to the beginning of the line:
|
|
375
|
-
|
|
376
|
-
```jsonc
|
|
377
|
-
"keymaps": {
|
|
378
|
-
"normal": {
|
|
379
|
-
"D": "d0"
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
Make `H` move to the beginning and `L` move to the end:
|
|
385
|
-
|
|
386
|
-
```jsonc
|
|
387
|
-
"keymaps": {
|
|
388
|
-
"normal": {
|
|
389
|
-
"H": "0",
|
|
390
|
-
"L": "$"
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
Use `q` to enter insert mode from normal mode:
|
|
396
|
-
|
|
397
|
-
```jsonc
|
|
398
|
-
"keymaps": {
|
|
399
|
-
"normal": {
|
|
400
|
-
"q": "insert"
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
Use a leader-style sequence:
|
|
406
|
-
|
|
407
|
-
```jsonc
|
|
408
|
-
"keymaps": {
|
|
409
|
-
"normal": {
|
|
410
|
-
"\\s": "submit",
|
|
411
|
-
"\\r": "<C-r>"
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"cursorStyles": {
|
|
67
|
+
"insert": { "style": "line", "blinking": false },
|
|
68
|
+
"normal": { "style": "block", "blinking": false }
|
|
412
69
|
}
|
|
413
70
|
}
|
|
414
71
|
```
|
|
415
72
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
If a keymap does not work, check these first:
|
|
73
|
+
### Debugging
|
|
419
74
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
- Ctrl keys use lowercase letters, such as `<C-s>`.
|
|
424
|
-
- The action string is not empty.
|
|
75
|
+
Set `"debug": true` or launch OpenCode with `VIM_PROMPT_DEBUG=1`. Invalid mappings
|
|
76
|
+
are skipped and recorded in the log. A custom `debugPath` should be absolute;
|
|
77
|
+
`~` is not expanded in configured paths.
|
|
425
78
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
"debug": true,
|
|
430
|
-
"debugPath": "/tmp/opencode-vim.log"
|
|
431
|
-
```
|
|
79
|
+
`keymapTimeout` controls partially typed custom mappings. If an insert-mode
|
|
80
|
+
mapping times out, its pending characters are inserted as ordinary text. Pending
|
|
81
|
+
keys are not shown in the footer.
|