opencode-quill 0.9.2 → 0.10.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/CHANGELOG.md +7 -0
- package/README.md +20 -24
- package/package.json +1 -1
- package/src/ghost.ts +131 -28
- package/src/keymap.ts +11 -3
- package/src/tui.tsx +17 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes are documented in this file using
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.10.0] - 2026-11-27
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **composer:** Show an alternatives picker above the active word (#36)
|
|
12
|
+
|
|
7
13
|
## [0.9.2] - 2026-11-27
|
|
8
14
|
|
|
9
15
|
### Fixed
|
|
@@ -193,6 +199,7 @@ All notable changes are documented in this file using
|
|
|
193
199
|
- `/quill` command and command palette action to toggle autocomplete.
|
|
194
200
|
- Local installer script, full test suite, CI workflows, and release tooling.
|
|
195
201
|
|
|
202
|
+
[0.10.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.9.2...v0.10.0
|
|
196
203
|
[0.9.2]: https://github.com/ozandogrultan/opencode-quill/compare/v0.9.1...v0.9.2
|
|
197
204
|
[0.9.1]: https://github.com/ozandogrultan/opencode-quill/compare/v0.9.0...v0.9.1
|
|
198
205
|
[0.9.0]: https://github.com/ozandogrultan/opencode-quill/compare/v0.8.0...v0.9.0
|
package/README.md
CHANGED
|
@@ -201,9 +201,9 @@ Restart OpenCode after editing `cli.json`.
|
|
|
201
201
|
| `minSuggestedWordLength` | `number` | `0` | Minimum number of characters in a suggested word, for both prose and shell suggestions; `0` allows any length. |
|
|
202
202
|
| `acceptKeys` | `string[]` | `["tab", "right"]` | Keys that accept and insert the active word suggestion. |
|
|
203
203
|
| `dismissKeys` | `string[]` | `["escape"]` | Keys that dismiss the visible suggestion without inserting. |
|
|
204
|
-
| `cycleNextKeys` | `string[]` | `[]` | Opt-in keys
|
|
205
|
-
| `cyclePreviousKeys` | `string[]` | `[]` | Opt-in keys
|
|
206
|
-
| `summonKeys` | `string[]` | `[]` | Opt-in keys to
|
|
204
|
+
| `cycleNextKeys` | `string[]` | `[]` | Opt-in keys to select the next alternative and open the picker, for example `["alt+n"]`. |
|
|
205
|
+
| `cyclePreviousKeys` | `string[]` | `[]` | Opt-in keys to select the previous alternative and open the picker, for example `["alt+p"]`. |
|
|
206
|
+
| `summonKeys` | `string[]` | `[]` | Opt-in keys to open the picker or summon candidates on demand, for example `["ctrl+y"]`. |
|
|
207
207
|
|
|
208
208
|
`completeAtLineEnd` uses prose context only up to the cursor while checking
|
|
209
209
|
code and attachment ranges across the full draft. It inserts only missing
|
|
@@ -212,32 +212,28 @@ replacements remain limited to chip-free draft ends. The suggestion must fit
|
|
|
212
212
|
the visible cursor row; it never overwrites the next line. Acceptance preserves
|
|
213
213
|
later lines, attachment metadata, host callbacks, and native undo/redo.
|
|
214
214
|
|
|
215
|
-
Quill shows one inline suggestion by default.
|
|
216
|
-
|
|
217
|
-
when space allows. Cycling changes only the ghost text; Tab accepts the
|
|
218
|
-
selected suggestion. The list wraps and skips alternatives that do not fit on
|
|
219
|
-
the cursor row. Without a visible alternative, cycle keys fall through.
|
|
215
|
+
Quill shows one inline suggestion by default. To open the alternatives picker
|
|
216
|
+
with Ctrl+Y, add this to the Quill plugin's `options`:
|
|
220
217
|
|
|
221
|
-
|
|
222
|
-
candidates for the current draft when no suggestion is visible. It falls
|
|
223
|
-
through when Quill has no eligible candidate. Editing the draft or moving the
|
|
224
|
-
cursor resets the summoned list.
|
|
225
|
-
|
|
226
|
-
Custom keybindings can also be overridden using OpenCode's standard
|
|
227
|
-
`keybinds` map in `cli.json`:
|
|
228
|
-
|
|
229
|
-
```jsonc
|
|
218
|
+
```json
|
|
230
219
|
{
|
|
231
|
-
"
|
|
232
|
-
"quill.accept": "tab",
|
|
233
|
-
"quill.dismiss": "ctrl+g",
|
|
234
|
-
"quill.next": "alt+n",
|
|
235
|
-
"quill.previous": "alt+p",
|
|
236
|
-
"quill.summon": "ctrl+y"
|
|
237
|
-
}
|
|
220
|
+
"summonKeys": ["ctrl+y"]
|
|
238
221
|
}
|
|
239
222
|
```
|
|
240
223
|
|
|
224
|
+
Press Ctrl+Y to see the available words above the active word. If no
|
|
225
|
+
automatic suggestion appears, Ctrl+Y can summon lower-confidence candidates.
|
|
226
|
+
While the list is visible, Up and Down move the highlight and the inline ghost previews the
|
|
227
|
+
selection. Tab accepts it, Escape closes the list, and editing the draft or
|
|
228
|
+
moving the cursor resets it. Enter keeps its usual behavior.
|
|
229
|
+
|
|
230
|
+
For direct cycling, optionally set `cycleNextKeys` to `["alt+n"]` and
|
|
231
|
+
`cyclePreviousKeys` to `["alt+p"]`. These open the picker and cycle immediately,
|
|
232
|
+
even without a summon key. If there isn't room above the word, the cycle keys
|
|
233
|
+
still work inline. With only a summon key, press it again to cycle inline.
|
|
234
|
+
Cycling skips suggestions that don't fit on the cursor row. Up and Down keep
|
|
235
|
+
their normal behavior when no picker is visible.
|
|
236
|
+
|
|
241
237
|
Quill's accept/dismiss/cycle layer runs in base mode at priority `2`, only in
|
|
242
238
|
the focused normal composer. A visible suggestion takes Tab/Right for
|
|
243
239
|
acceptance and Escape for dismissal. With no eligible visible suggestion,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-quill",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "OpenCode prompt autocomplete: local n-gram word and next-word prediction shown as inline ghost text in the TUI composer, accepted with Tab.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/ghost.ts
CHANGED
|
@@ -12,6 +12,39 @@ export type Composer = {
|
|
|
12
12
|
enabled: boolean
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
type Alternatives = {
|
|
16
|
+
summon?: string
|
|
17
|
+
cycle: boolean
|
|
18
|
+
accept?: string
|
|
19
|
+
dismiss?: string
|
|
20
|
+
colors: {
|
|
21
|
+
text: RGBA
|
|
22
|
+
muted: RGBA
|
|
23
|
+
background: RGBA
|
|
24
|
+
selectedText: RGBA
|
|
25
|
+
selectedBackground: RGBA
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type CandidateMemo = {
|
|
30
|
+
text: string
|
|
31
|
+
offset: number
|
|
32
|
+
marks: string
|
|
33
|
+
revision: number
|
|
34
|
+
predictor: WordPredictor
|
|
35
|
+
predictions: Prediction[]
|
|
36
|
+
index: number
|
|
37
|
+
summoned: boolean
|
|
38
|
+
prefix: string
|
|
39
|
+
picker: boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type PaintedSuggestion = {
|
|
43
|
+
memo: CandidateMemo
|
|
44
|
+
prediction: Prediction
|
|
45
|
+
picker?: { geometry: string; drawn: boolean }
|
|
46
|
+
}
|
|
47
|
+
|
|
15
48
|
export function dimGhostColor(muted: RGBA): RGBA {
|
|
16
49
|
return RGBA.fromValues(muted.r, muted.g, muted.b, muted.a * 0.55)
|
|
17
50
|
}
|
|
@@ -40,9 +73,9 @@ export function findComposer(marker: Renderable | undefined, isEditor: (node: Re
|
|
|
40
73
|
}
|
|
41
74
|
|
|
42
75
|
export class ComposerGhost {
|
|
43
|
-
private shown:
|
|
76
|
+
private shown: PaintedSuggestion | undefined
|
|
44
77
|
private dismissed: { text: string; offset: number } | undefined
|
|
45
|
-
private memo:
|
|
78
|
+
private memo: CandidateMemo | undefined
|
|
46
79
|
private disposed = false
|
|
47
80
|
private readonly draw: (buffer: OptimizedBuffer, delta: number) => void
|
|
48
81
|
|
|
@@ -54,7 +87,7 @@ export class ComposerGhost {
|
|
|
54
87
|
private readonly renderer: CliRenderer,
|
|
55
88
|
private readonly completeAtLineEnd = false,
|
|
56
89
|
private readonly shellPredictor?: WordPredictor,
|
|
57
|
-
private readonly
|
|
90
|
+
private readonly alternatives?: () => Alternatives,
|
|
58
91
|
) {
|
|
59
92
|
this.draw = (buffer) => { if (!this.disposed) this.paint(buffer) }
|
|
60
93
|
renderer.addPostProcessFn(this.draw)
|
|
@@ -112,17 +145,59 @@ export class ComposerGhost {
|
|
|
112
145
|
if (!allowReplacement && predictions[0]?.replace) predictions.length = 0
|
|
113
146
|
else if (!allowReplacement) predictions.splice(0, predictions.length, ...predictions.filter((prediction) => !prediction.replace))
|
|
114
147
|
const last = this.shown
|
|
115
|
-
if (query && !query.next && offset === text.length && last && last.offset === last.text.length &&
|
|
116
|
-
const typed = text.slice(last.text.length)
|
|
148
|
+
if (query && !query.next && offset === text.length && last && last.memo === this.memo && last.memo.offset === last.memo.text.length && last.memo.index === 0 && !last.memo.summoned && last.memo.revision === revision && last.memo.predictor === predictor && last.memo.marks === signature && !last.prediction.replace && text.startsWith(last.memo.text)) {
|
|
149
|
+
const typed = text.slice(last.memo.text.length)
|
|
117
150
|
if (typed && last.prediction.suffix.startsWith(typed) && typed.length < last.prediction.suffix.length) {
|
|
118
151
|
const sticky = { ...last.prediction, suffix: last.prediction.suffix.slice(typed.length) }
|
|
119
152
|
predictions.splice(0, predictions.length, sticky, ...predictions.filter((prediction) => prediction.word !== sticky.word))
|
|
120
153
|
}
|
|
121
154
|
}
|
|
122
|
-
this.memo = { text, offset, marks: signature, revision, predictor, predictions, index: 0, summoned: false }
|
|
155
|
+
this.memo = { text, offset, marks: signature, revision, predictor, predictions, index: 0, summoned: false, prefix: query?.prefix ?? "", picker: false }
|
|
123
156
|
return predictions[0]
|
|
124
157
|
}
|
|
125
158
|
|
|
159
|
+
private pickerGeometry(): string {
|
|
160
|
+
const { visualCol, visualRow } = this.editor.visualCursor
|
|
161
|
+
return [this.renderer.width, this.renderer.height, this.editor.screenX, this.editor.screenY,
|
|
162
|
+
this.editor.width, visualCol, visualRow].join(":")
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private paintPicker(buffer: OptimizedBuffer, x: number, y: number, fitting: Prediction[], prediction: Prediction, options: Alternatives): boolean {
|
|
166
|
+
const { prefix } = this.memo!
|
|
167
|
+
const prefixWidth = this.editor.editBuffer.measureText(prefix)
|
|
168
|
+
const cursor = this.editor.visualCursor
|
|
169
|
+
if (cursor.visualRow !== 0 || cursor.visualCol < prefixWidth || y < fitting.length) return false
|
|
170
|
+
const terms = fitting.map((candidate) => candidate.replace ? candidate.suffix : prefix + candidate.suffix)
|
|
171
|
+
const measure = (text: string) => this.editor.editBuffer.measureText(text)
|
|
172
|
+
const termWidth = Math.max(...terms.map(measure)) + 3
|
|
173
|
+
const left = Math.max(0, this.editor.screenX)
|
|
174
|
+
const right = Math.min(buffer.width, this.editor.screenX + this.editor.width)
|
|
175
|
+
if (termWidth > Math.min(48, right - left)) return false
|
|
176
|
+
const start = Math.max(left, Math.min(x - prefixWidth - 2, right - termWidth))
|
|
177
|
+
const fullHelp = ["↑/↓ move", options.accept && `${options.accept} accept`, options.dismiss && `${options.dismiss} close`].filter(Boolean).join(" · ")
|
|
178
|
+
const help = y > fitting.length
|
|
179
|
+
? [fullHelp, "↑/↓ move"].find((label) => measure(label) + 3 <= Math.min(48, right - start))
|
|
180
|
+
: undefined
|
|
181
|
+
const width = Math.max(termWidth, help ? measure(help) + 3 : 0)
|
|
182
|
+
const height = fitting.length + Number(!!help)
|
|
183
|
+
const top = y - height
|
|
184
|
+
const { colors } = options
|
|
185
|
+
buffer.pushScissorRect(start, top, width, height)
|
|
186
|
+
try {
|
|
187
|
+
buffer.fillRect(start, top, width, height, colors.background)
|
|
188
|
+
terms.forEach((term, index) => {
|
|
189
|
+
const selected = fitting[index] === prediction
|
|
190
|
+
if (selected) buffer.fillRect(start, top + index, width, 1, colors.selectedBackground)
|
|
191
|
+
buffer.drawText(`${selected ? "› " : " "}${term}`, start, top + index,
|
|
192
|
+
selected ? colors.selectedText : colors.text, selected ? colors.selectedBackground : colors.background)
|
|
193
|
+
})
|
|
194
|
+
if (help) buffer.drawText(help, start + 2, y - 1, colors.muted, colors.background)
|
|
195
|
+
} finally {
|
|
196
|
+
buffer.popScissorRect()
|
|
197
|
+
}
|
|
198
|
+
return true
|
|
199
|
+
}
|
|
200
|
+
|
|
126
201
|
private paint(buffer: OptimizedBuffer): void {
|
|
127
202
|
if (this.editor.isDestroyed) {
|
|
128
203
|
this.shown = undefined
|
|
@@ -132,6 +207,7 @@ export class ComposerGhost {
|
|
|
132
207
|
const offset = this.offset()
|
|
133
208
|
const prediction = this.prediction(text, offset)
|
|
134
209
|
if (!prediction) {
|
|
210
|
+
if (this.memo) this.memo.picker = false
|
|
135
211
|
this.shown = undefined
|
|
136
212
|
return
|
|
137
213
|
}
|
|
@@ -144,39 +220,49 @@ export class ComposerGhost {
|
|
|
144
220
|
}
|
|
145
221
|
const x = this.editor.screenX + cursor.visualCol
|
|
146
222
|
const y = this.editor.screenY + cursor.visualRow
|
|
223
|
+
const memo = this.memo!
|
|
224
|
+
const fitting = memo.predictions.length > 1 ? memo.predictions.filter((candidate) => this.fits(candidate)) : []
|
|
225
|
+
const options = fitting.length > 1 ? this.alternatives?.() : undefined
|
|
226
|
+
const attempted = memo.picker && fitting.length > 1
|
|
227
|
+
const picker = !!options && attempted && this.paintPicker(buffer, x, y, fitting, prediction, options)
|
|
147
228
|
buffer.pushScissorRect(x, y, room, 1)
|
|
148
229
|
try {
|
|
149
230
|
const color = this.color()
|
|
150
231
|
buffer.drawText(ghost, x, y, color, this.editor.backgroundColor)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
232
|
+
if (options && !picker && (options.summon || options.cycle || memo.picker)) {
|
|
233
|
+
const counter = ` ${fitting.indexOf(prediction) + 1}/${fitting.length}`
|
|
234
|
+
const hint = options.summon && (!attempted || !options.cycle)
|
|
235
|
+
? ` ${options.summon} ${attempted ? "cycles" : "for"} ${fitting.length} choices`
|
|
236
|
+
: counter
|
|
237
|
+
const width = this.editor.editBuffer.measureText(ghost)
|
|
238
|
+
for (const label of hint === counter ? [counter] : [hint, counter]) {
|
|
239
|
+
if (width + this.editor.editBuffer.measureText(label) > room) continue
|
|
240
|
+
buffer.drawText(label, x + width, y, dimGhostColor(color), this.editor.backgroundColor)
|
|
241
|
+
break
|
|
160
242
|
}
|
|
161
243
|
}
|
|
162
244
|
} finally {
|
|
163
245
|
buffer.popScissorRect()
|
|
164
246
|
}
|
|
165
|
-
this.shown = {
|
|
247
|
+
this.shown = { memo, prediction, picker: attempted ? { geometry: this.pickerGeometry(), drawn: picker } : undefined }
|
|
166
248
|
}
|
|
167
249
|
|
|
168
250
|
accept(): boolean {
|
|
169
251
|
const shown = this.shown
|
|
170
252
|
if (!shown || !this.visible()) return false
|
|
253
|
+
const { memo } = shown
|
|
254
|
+
const prediction = memo.predictions[memo.index]
|
|
255
|
+
if (prediction !== shown.prediction && (!this.pickerVisible() || !this.fits(prediction))) return false
|
|
171
256
|
const marks = this.editor.extmarks.getAll()
|
|
172
|
-
if (!completionQuery(
|
|
173
|
-
if ((marks.length ||
|
|
257
|
+
if (!completionQuery(memo.text, memo.offset, this.protectedRanges(marks), this.completeAtLineEnd, memo.predictor.grammar)) return false
|
|
258
|
+
if ((marks.length || memo.offset !== memo.text.length) && prediction.replace) return false
|
|
259
|
+
memo.picker = false
|
|
174
260
|
this.shown = undefined
|
|
175
|
-
if (
|
|
176
|
-
this.editor.replaceText(
|
|
261
|
+
if (prediction.replace) {
|
|
262
|
+
this.editor.replaceText(memo.text.slice(0, memo.text.length - prediction.replace) + prediction.suffix)
|
|
177
263
|
this.editor.gotoBufferEnd()
|
|
178
264
|
} else {
|
|
179
|
-
this.editor.insertText(
|
|
265
|
+
this.editor.insertText(prediction.suffix)
|
|
180
266
|
}
|
|
181
267
|
this.editor.requestRender()
|
|
182
268
|
return true
|
|
@@ -184,24 +270,41 @@ export class ComposerGhost {
|
|
|
184
270
|
|
|
185
271
|
dismiss(): boolean {
|
|
186
272
|
if (!this.visible()) return false
|
|
187
|
-
|
|
273
|
+
const { memo } = this.shown!
|
|
274
|
+
if (!this.pickerVisible()) this.dismissed = { text: memo.text, offset: memo.offset }
|
|
275
|
+
memo.picker = false
|
|
188
276
|
this.shown = undefined
|
|
189
277
|
this.editor.requestRender()
|
|
190
278
|
return true
|
|
191
279
|
}
|
|
192
280
|
|
|
193
281
|
visible(): boolean {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
282
|
+
const shown = this.shown
|
|
283
|
+
if (this.disposed || !shown || shown.memo !== this.memo || !eligibleComposer(this.view())) return false
|
|
284
|
+
const { memo, prediction } = shown
|
|
285
|
+
return this.editor.plainText === memo.text && this.offset() === memo.offset &&
|
|
286
|
+
this.marksKey() === memo.marks && this.active() === memo.predictor && memo.predictor.modelRevision === memo.revision && this.fits(prediction)
|
|
197
287
|
}
|
|
198
288
|
|
|
199
289
|
canCycle(): boolean {
|
|
200
290
|
return this.visible() && this.memo!.predictions.some((prediction, index) => index !== this.memo!.index && this.fits(prediction))
|
|
201
291
|
}
|
|
202
292
|
|
|
293
|
+
pickerVisible(): boolean {
|
|
294
|
+
const picker = this.shown?.picker
|
|
295
|
+
return picker?.drawn === true && this.visible() && picker.geometry === this.pickerGeometry()
|
|
296
|
+
}
|
|
297
|
+
|
|
203
298
|
summon(): boolean {
|
|
204
|
-
if (this.
|
|
299
|
+
if (this.visible()) {
|
|
300
|
+
if (!this.canCycle()) return false
|
|
301
|
+
const picker = this.shown!.picker
|
|
302
|
+
if (picker?.drawn === false && picker.geometry === this.pickerGeometry()) return this.cycle(1)
|
|
303
|
+
this.memo!.picker = true
|
|
304
|
+
this.editor.requestRender()
|
|
305
|
+
return true
|
|
306
|
+
}
|
|
307
|
+
if (this.disposed || !eligibleComposer(this.view())) return false
|
|
205
308
|
const text = this.editor.plainText
|
|
206
309
|
const offset = this.offset()
|
|
207
310
|
const automatic = this.prediction(text, offset)
|
|
@@ -215,7 +318,7 @@ export class ComposerGhost {
|
|
|
215
318
|
(allowReplacement || !prediction.replace) && this.fits(prediction))
|
|
216
319
|
if (!predictions.length) return false
|
|
217
320
|
this.dismissed = undefined
|
|
218
|
-
this.memo = { text, offset, marks: this.marksKey(), revision: predictor.modelRevision, predictor, predictions, index: 0, summoned: true }
|
|
321
|
+
this.memo = { text, offset, marks: this.marksKey(), revision: predictor.modelRevision, predictor, predictions, index: 0, summoned: true, prefix: query.prefix, picker: predictions.length > 1 }
|
|
219
322
|
this.editor.requestRender()
|
|
220
323
|
return true
|
|
221
324
|
}
|
|
@@ -226,7 +329,7 @@ export class ComposerGhost {
|
|
|
226
329
|
do {
|
|
227
330
|
memo.index = (memo.index + direction + memo.predictions.length) % memo.predictions.length
|
|
228
331
|
} while (!this.fits(memo.predictions[memo.index]))
|
|
229
|
-
|
|
332
|
+
memo.picker = true
|
|
230
333
|
this.editor.requestRender()
|
|
231
334
|
return true
|
|
232
335
|
}
|
package/src/keymap.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { KeymapLayer } from "@opencode/plugin/tui/context"
|
|
2
2
|
import type { Options } from "./options"
|
|
3
3
|
|
|
4
|
-
type Suggestion = { visible(): boolean; accept(): boolean; dismiss(): boolean; canCycle(): boolean; cycle(direction: 1 | -1): boolean; summon(): boolean }
|
|
4
|
+
type Suggestion = { visible(): boolean; accept(): boolean; dismiss(): boolean; canCycle(): boolean; cycle(direction: 1 | -1): boolean; summon(): boolean; pickerVisible(): boolean }
|
|
5
5
|
|
|
6
6
|
export function completionLayer(options: Options, suggestion: () => Suggestion | undefined): KeymapLayer {
|
|
7
7
|
return {
|
|
@@ -25,16 +25,24 @@ export function completionLayer(options: Options, suggestion: () => Suggestion |
|
|
|
25
25
|
...([["next", 1, options.cycleNextKeys], ["previous", -1, options.cyclePreviousKeys]] as const).map(([name, direction, keys]) => ({
|
|
26
26
|
id: `quill.${name}`,
|
|
27
27
|
title: `${name === "next" ? "Next" : "Previous"} word suggestion`,
|
|
28
|
-
bind: keys.
|
|
28
|
+
bind: keys.join(",") || undefined,
|
|
29
29
|
enabled: () => suggestion()?.canCycle() === true,
|
|
30
30
|
run: () => suggestion()?.cycle(direction) ? undefined : false,
|
|
31
31
|
})),
|
|
32
32
|
{
|
|
33
33
|
id: "quill.summon",
|
|
34
34
|
title: "Summon word suggestions",
|
|
35
|
-
bind: options.summonKeys.
|
|
35
|
+
bind: options.summonKeys.join(",") || undefined,
|
|
36
36
|
run: () => suggestion()?.summon() ? undefined : false,
|
|
37
37
|
},
|
|
38
|
+
...([["down", 1], ["up", -1]] as const).map(([bind, direction]) => ({
|
|
39
|
+
bind,
|
|
40
|
+
enabled: () => suggestion()?.pickerVisible() === true,
|
|
41
|
+
run: () => {
|
|
42
|
+
const current = suggestion()
|
|
43
|
+
return current?.pickerVisible() && current.cycle(direction) ? undefined : false
|
|
44
|
+
},
|
|
45
|
+
})),
|
|
38
46
|
],
|
|
39
47
|
}
|
|
40
48
|
}
|
package/src/tui.tsx
CHANGED
|
@@ -71,8 +71,23 @@ export default Plugin.define({
|
|
|
71
71
|
selected: context.renderer.hasSelection,
|
|
72
72
|
enabled: !disposed && settings.enabled && (!shell || shellEnabled()) && currentEditor() === editor,
|
|
73
73
|
}
|
|
74
|
-
}, () => dimGhostColor(context.theme.text.muted), context.renderer, options.completeAtLineEnd, shellPredictor,
|
|
75
|
-
|
|
74
|
+
}, () => dimGhostColor(context.theme.text.muted), context.renderer, options.completeAtLineEnd, shellPredictor, () => {
|
|
75
|
+
const shortcut = (id: string) => context.keymap.shortcuts(id).map((key) => key.trim()).find((key) => key && !/[\u0000-\u001f\u007f-\u009f]/u.test(key))
|
|
76
|
+
const { text, background } = context.theme
|
|
77
|
+
return {
|
|
78
|
+
summon: shortcut("quill.summon"),
|
|
79
|
+
cycle: !!(shortcut("quill.next") || shortcut("quill.previous")),
|
|
80
|
+
accept: shortcut("quill.accept"),
|
|
81
|
+
dismiss: shortcut("quill.dismiss"),
|
|
82
|
+
colors: {
|
|
83
|
+
text: text.base,
|
|
84
|
+
muted: text.muted,
|
|
85
|
+
background: background.raised.base,
|
|
86
|
+
selectedText: text.selection,
|
|
87
|
+
selectedBackground: background.selection,
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
})
|
|
76
91
|
}
|
|
77
92
|
|
|
78
93
|
const sessionInfo = (sessionID: string) =>
|