Skip to content

herrnel/clankeryank

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClankerYank

Send code selections from Neovim into a pi prompt without copy-pasting.

Yank code with :ClankerYank in nvim → a [+ path:lines] token appears in your pi prompt → submit → pi sees the full code block expanded inline.

Status: works on localhost. Not packaged for distribution yet. See ~/project-ideas/clankeryank-v2-nvim-rpc.md for the planned v2 redesign that drops the HTTP server.

How it works

┌──────────┐  POST /append-block   ┌──────────────┐
│  Neovim  │ ───────────────────► │  Rust server │
│  :CY cmd │                       │ (axum, 3000) │
└──────────┘                       └──────┬───────┘
                                          │ GET /get-context?since=N
                                          ▼
                                   ┌──────────────┐
                                   │ pi extension │
                                   │ (polls 1s)   │
                                   └──────┬───────┘
                                          │ injects [+ path:lines] token
                                          │ into the prompt editor
                                          ▼
                              user types → submits
                                          │
                              tokens expanded → fenced code → sent to LLM
                                          │
                              DELETE /context, reset state

Three runtimes, one direction of data flow per step. The pi extension is the only component that mutates editor state.

Components

Path What it is
nvim/ Lua plugin — registers :ClankerYank / :CY
pi-extension/ TypeScript pi extension — polls, injects, expands
server/ Rust HTTP server — holds the accumulated blocks

Requirements

  • Rust 1.75+ (cargo)
  • Neovim 0.10+ (uses vim.system)
  • pi v? (whatever version exposes addAutocompleteProvider and the input event — current as of 2026)

Setup

1. Build and run the server

cd server
cargo run
# expect: listening on 127.0.0.1:3000

Keep this running in a terminal. There is no daemonization yet.

2. Install the Neovim plugin

Drop nvim/lua/user/clankeryank.lua onto your runtimepath and require it. For a chezmoi-managed config:

cp nvim/lua/user/clankeryank.lua ~/.config/nvim/lua/user/clankeryank.lua

Or symlink during development:

ln -s "$PWD/nvim/lua/user/clankeryank.lua" ~/.config/nvim/lua/user/clankeryank.lua

In your init.lua:

require("user.clankeryank")

3. Install the pi extension

Pi auto-discovers extensions from ~/.pi/agent/extensions/<name>/index.ts. Symlink the extension directory:

ln -s "$PWD/pi-extension" ~/.pi/agent/extensions/ClankerYank

Restart pi (or /reload). You should see a toast: connected to server.

Usage

  1. In nvim, visually select a range and run :ClankerYank (or :CY).
  2. Within ~1s, a token like [+ /path/to/file.rs:10-25] appears in your pi prompt.
  3. Repeat for as many ranges as you want. Multiple files, multiple ranges.
  4. Type the rest of your prompt around the tokens.
  5. Submit. Pi expands each token to a fenced code block before sending to the LLM, then clears the server.

Known limitations

  • Polls every 1s; up to 1s of latency between :CY and the token appearing.
  • Hardcoded TCP port 127.0.0.1:3000.
  • Single global state on the server — two pi sessions or two nvim instances will stomp on each other.
  • The server has no persistence; restart it and you lose any pending blocks.
  • No --detach on the nvim curl call; very slow servers could briefly block :CY.
  • Tokens use absolute paths and can get long. Project-relative paths are a planned polish.

Development

The pi extension's debug ctx.ui.notify calls in resolveHttpServer are loud. Gate them on a DEBUG flag or remove before sharing.

To iterate on the pi extension without restarting pi, use /reload.

To iterate on the nvim plugin, :source % after editing.

To iterate on the server, cargo run re-builds and re-binds the port (kill the old process first).

License

TBD.

About

Lets your pi agent see what file your looking quickly while using NVIM.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors