pi-vim 0.9.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 +3 -1
- package/clipboard-policy.ts +7 -57
- package/index.ts +537 -277
- 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
|
@@ -32,6 +32,8 @@ Clipboard write mirroring is controlled by `piVim.clipboardMirror`:
|
|
|
32
32
|
|
|
33
33
|
The setting controls which local register writes cross the OS clipboard boundary. `p` / `P` keep non-mirrored writes local.
|
|
34
34
|
|
|
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.
|
|
36
|
+
|
|
35
37
|
## wrapping pi-vim
|
|
36
38
|
|
|
37
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.
|
|
@@ -72,7 +74,7 @@ u # undo
|
|
|
72
74
|
2} # jump two paragraphs forward
|
|
73
75
|
```
|
|
74
76
|
|
|
75
|
-
Mode indicator (`INSERT` / `NORMAL` / `EX`) appears bottom-right, theme-colored.
|
|
77
|
+
Mode indicator (`INSERT` / `NORMAL` / `EX`) appears bottom-right, theme-colored and configurable.
|
|
76
78
|
|
|
77
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.
|
|
78
80
|
|
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
|
}
|