pi-vim 0.8.0 → 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/README.md +10 -14
- package/clipboard-policy.ts +7 -57
- package/index.ts +546 -281
- package/motions.ts +38 -15
- package/package.json +3 -3
- package/settings.ts +92 -0
- package/text-objects.ts +38 -15
- package/word-boundary-cache.ts +5 -4
package/README.md
CHANGED
|
@@ -30,26 +30,22 @@ Clipboard write mirroring is controlled by `piVim.clipboardMirror`:
|
|
|
30
30
|
| `yank` | Mirror yanks only; deletes/changes update only pi-vim's internal register |
|
|
31
31
|
| `never` | Never mirror register writes to the OS clipboard |
|
|
32
32
|
|
|
33
|
-
The setting controls
|
|
33
|
+
The setting controls which local register writes cross the OS clipboard boundary. `p` / `P` keep non-mirrored writes local.
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Supported: `pi-vim` first, `@jordyvd/pi-image-attachments` second. pi-vim does not call `ctx.ui.getEditorComponent()`; the wrapper does. Inverse order unsupported.
|
|
35
|
+
Mode colors: `piVim.modeColors` accepts pi theme tokens (`insert`: `borderMuted`, `normal`: `borderAccent`, `ex`: `warning`); missing keys and unknown tokens use defaults. `piVim.syncBorderColorWithMode` defaults `false`; `true` syncs border to mode, overriding Pi's normal thinking-level border signal.
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
## wrapping pi-vim
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
Supported: `pi-vim` first, `@jordyvd/pi-image-attachments` second. pi-vim does not wrap previous editors; wrappers decorate in place or forward the CustomEditor surface: lifecycle (`handleInput`, `render`, `invalidate`), text (`getText`, `setText`, `insertTextAtCursor`, `getExpandedText`), callbacks, `actionHandlers`, flags, reads (`getLines`, `getCursor`, `getMode()`). Inverse order, insert delegates, and generic composition are unsupported.
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
Smoke:
|
|
44
42
|
|
|
45
43
|
```bash
|
|
46
|
-
# repo root
|
|
47
44
|
pi -e ./index.ts -e ../pi-image-attachments/index.ts
|
|
48
|
-
# this worktree
|
|
49
45
|
pi -e ./index.ts -e ../../../pi-image-attachments/index.ts
|
|
50
46
|
```
|
|
51
47
|
|
|
52
|
-
Check: insert text; add/paste image path; see `[Image #1]
|
|
48
|
+
Check: insert text; add/paste image path; see `[Image #1]`; submit text+image stripped; switch INSERT/NORMAL.
|
|
53
49
|
|
|
54
50
|
## contributor setup
|
|
55
51
|
|
|
@@ -78,7 +74,7 @@ u # undo
|
|
|
78
74
|
2} # jump two paragraphs forward
|
|
79
75
|
```
|
|
80
76
|
|
|
81
|
-
Mode indicator (`INSERT` / `NORMAL` / `EX`) appears bottom-right, theme-colored.
|
|
77
|
+
Mode indicator (`INSERT` / `NORMAL` / `EX`) appears bottom-right, theme-colored and configurable.
|
|
82
78
|
|
|
83
79
|
Requires `@mariozechner/pi-tui >= 0.47.0`. With `pi-tui >= 0.49.3` and DECSCUSR support, cursor shape follows mode; otherwise software cursor remains.
|
|
84
80
|
|
|
@@ -297,8 +293,7 @@ implemented and cancel the pending operator. Linewise counted yank (`{count}yy`,
|
|
|
297
293
|
| `{count}p` | Put `{count}` times after cursor |
|
|
298
294
|
| `{count}P` | Put `{count}` times before cursor |
|
|
299
295
|
|
|
300
|
-
Put reads the OS clipboard first
|
|
301
|
-
Paste text ending in `\n` is treated as line-wise.
|
|
296
|
+
Put reads the OS clipboard first unless the last local register write was not mirrored. Paste text ending in `\n` is line-wise.
|
|
302
297
|
|
|
303
298
|
---
|
|
304
299
|
|
|
@@ -320,7 +315,8 @@ Paste text ending in `\n` is treated as line-wise.
|
|
|
320
315
|
- `piVim.clipboardMirror = "yank"` mirrors yanks only; deletes and changes update only pi-vim's internal shadow.
|
|
321
316
|
- `piVim.clipboardMirror = "never"` disables write mirroring while keeping internal register writes synchronous.
|
|
322
317
|
- Rapid mirrored writes coalesce: only the latest pending value is guaranteed to be mirrored.
|
|
323
|
-
- `p` / `P` read the OS clipboard first, falling back to the shadow on read failure/timeout.
|
|
318
|
+
- `p` / `P` read the OS clipboard first when no local write was skipped by policy, falling back to the shadow on read failure/timeout.
|
|
319
|
+
- If policy skipped the last local write, `p` / `P` use the shadow so delete/yank → put works without touching the OS clipboard.
|
|
324
320
|
- While a mirror is in flight, `p` / `P` use the shadow so immediate yank/delete → put stays ordered.
|
|
325
321
|
- Pi owns the terminal clipboard backends; on Wayland external state may lag while the shadow stays authoritative for immediate puts.
|
|
326
322
|
|
package/clipboard-policy.ts
CHANGED
|
@@ -1,73 +1,23 @@
|
|
|
1
|
-
import { SettingsManager } from "@mariozechner/pi-coding-agent";
|
|
2
|
-
|
|
3
1
|
export type ClipboardMirrorPolicy = "all" | "yank" | "never";
|
|
4
2
|
export type RegisterWriteSource = "mutation" | "yank";
|
|
5
|
-
|
|
6
3
|
export const DEFAULT_CLIPBOARD_MIRROR_POLICY: ClipboardMirrorPolicy = "all";
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type UnknownRecord = Record<string, unknown>;
|
|
11
|
-
|
|
12
|
-
const missing = Symbol();
|
|
13
|
-
|
|
14
|
-
function formatInvalid(value: unknown) {
|
|
15
|
-
const type = value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
|
|
5
|
+
function fmt(v: unknown) {
|
|
6
|
+
const type = v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
|
|
16
7
|
try {
|
|
17
|
-
return `${JSON.stringify(
|
|
8
|
+
return `${JSON.stringify(v) ?? type} (type ${type})`;
|
|
18
9
|
} catch {
|
|
19
10
|
return `(type ${type})`;
|
|
20
11
|
}
|
|
21
12
|
}
|
|
22
13
|
|
|
23
|
-
function readSetting(settings: unknown): unknown {
|
|
24
|
-
if (typeof settings !== "object" || settings === null || !Object.hasOwn(settings, "piVim")) return missing;
|
|
25
|
-
const piVim = (settings as UnknownRecord).piVim;
|
|
26
|
-
if (typeof piVim !== "object" || piVim === null || Array.isArray(piVim)) return piVim;
|
|
27
|
-
return Object.hasOwn(piVim, "clipboardMirror") ? (piVim as UnknownRecord).clipboardMirror : missing;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
14
|
export function resolveClipboardMirrorPolicy(value: unknown) {
|
|
31
15
|
if (value === undefined) return { policy: DEFAULT_CLIPBOARD_MIRROR_POLICY };
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
if (policy === "all" || policy === "yank" || policy === "never") {
|
|
36
|
-
return { policy: policy as ClipboardMirrorPolicy };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
16
|
+
const p = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
17
|
+
if (p === "all" || p === "yank" || p === "never")
|
|
18
|
+
return { policy: p as ClipboardMirrorPolicy };
|
|
40
19
|
return {
|
|
41
20
|
policy: DEFAULT_CLIPBOARD_MIRROR_POLICY,
|
|
42
|
-
warning: `Invalid piVim.clipboardMirror ${
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function readPiVimClipboardMirrorSetting(globalSettings: unknown, projectSettings: unknown): unknown | undefined {
|
|
47
|
-
const project = readSetting(projectSettings);
|
|
48
|
-
if (project !== missing) return project;
|
|
49
|
-
const global = readSetting(globalSettings);
|
|
50
|
-
return global === missing ? undefined : global;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function readPiVimSettingsFromDisk(cwd: string): PiVimSettings {
|
|
54
|
-
const settings = SettingsManager.create(cwd);
|
|
55
|
-
return {
|
|
56
|
-
clipboardMirror: readPiVimClipboardMirrorSetting(settings.getGlobalSettings(), settings.getProjectSettings()),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let piVimSettingsReader = readPiVimSettingsFromDisk;
|
|
61
|
-
|
|
62
|
-
export function readPiVimSettings(cwd: string) {
|
|
63
|
-
return piVimSettingsReader(cwd);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function setPiVimSettingsReaderForTests(reader: typeof readPiVimSettingsFromDisk) {
|
|
67
|
-
const prev = piVimSettingsReader;
|
|
68
|
-
piVimSettingsReader = reader;
|
|
69
|
-
|
|
70
|
-
return () => {
|
|
71
|
-
piVimSettingsReader = prev;
|
|
21
|
+
warning: `Invalid piVim.clipboardMirror ${fmt(value)}; expected all, yank, never.`,
|
|
72
22
|
};
|
|
73
23
|
}
|