Files
dots/common/.pi/agent/extensions/vim-toggle.ts
T
coja a700e23e0a [Sync] adopt unified stow layout from the private repo
Mirrors the private dots tree at 900bdda: one shared base plus per-host
overlays, replacing the old flat .config/ layout (last synced 2026-06-28).

- packages: common/ gui/ wm/ lw/ fl/ + install.sh and bin/ tooling (dotsync,
  reconcile-hyde.sh)
- new README (layout, deploy order, HyDE dependency), plus ToDo.md and
  HYDE-UPDATE.md
- current HyDE waybar rig (layouts/, cava), pi agent extensions, claude/
  config, tmux, presenterm, aichat roles
- drops stale duplicates and generated cruft that should never have been
  tracked: the second top-level .pi/ copy, btop.log, zellij config.kdl.bak,
  fish_variables, nvim codecompanion.lua
- .pi/agent/auth.json is gitignored now; auth.json.example ships instead
- fl/ and wm/ hypr themes/ stay untracked (HyDE-generated per machine, per
  the root .gitignore)
2026-08-12 22:50:18 +02:00

45 lines
1.9 KiB
TypeScript

/**
* `/vim` — toggle the modal input editor off/on
*
* The modal editor itself is now the **npm package `pi-vim`** (declared in
* `settings.json > packages`, configured under `settings.json > piVim`). That
* package registers no commands, so this file restores the `/vim` toggle the
* local `vim-editor.ts` fork used to provide — the fork is kept beside it as
* `vim-editor.ts.disabled` (see ../../CLAUDE.md).
*
* OFF — drop the custom editor component, which puts pi's stock editor back for
* the rest of the session (handy for a big paste, or any key the modal
* layer swallows).
* ON — `ctx.reload()`, the same flow as `/reload`, re-runs extension discovery
* and so re-installs pi-vim's editor. That reloads statusbar/plan-mode too
* and re-instantiates *this* file, which is why turning it back on needs no
* bookkeeping: the fresh instance starts at `enabled = true` again.
*
* Nothing is installed on `session_start` — pi-vim already does that, so this
* file only ever reacts to the command and never races it for the editor slot.
*/
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
export default function (pi: ExtensionAPI) {
// pi-vim installs its editor at session_start, so we start out enabled.
let enabled = true;
pi.registerCommand("vim", {
description: "Toggle the vim (modal) input editor",
handler: async (_args, ctx) => {
if (ctx.mode !== "tui") return; // editor components are TUI-only
if (enabled) {
ctx.ui.setEditorComponent(undefined);
enabled = false;
ctx.ui.notify("Default editor restored — /vim to re-enable", "info");
return;
}
// Notify *before* awaiting: after the reload this call frame belongs to
// the pre-reload instance, and its UI handle is on the way out.
ctx.ui.notify("Vim editor enabled", "info");
await ctx.reload();
},
});
}