@maxpaulus/pi-nvim

Send prompts and editor context from Neovim to the active Pi conversation

Packages

Package details

extension

Install @maxpaulus/pi-nvim from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@maxpaulus/pi-nvim
Package
@maxpaulus/pi-nvim
Version
0.1.1
Published
Aug 19, 2026
Downloads
338/mo · 7/wk
Author
maxpaulus
License
MIT
Types
extension
Size
23.4 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./pi-extension/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@maxpaulus/pi-nvim

Send a prompt and the current Neovim context to the conversation open in Pi.

  • <leader>ai opens a prompt input.
  • If Pi is running with the included extension, the prompt becomes a real user message in its active conversation.
  • If Pi is busy, the message is queued as a follow-up.
  • If no Pi instance is available, Neovim opens a split running Pi with the prompt as its first message.
  • Modified file buffers are saved before the prompt is sent, so Pi edits the current version.
  • Successful Pi edit and write calls automatically reload matching unmodified buffers.
  • Normal mode includes a bounded excerpt around the cursor. Visual mode includes the selected lines.

Requirements

  • Neovim 0.10 or newer
  • Pi 0.84 or newer
  • macOS or Linux (the transport uses a Unix domain socket)

Install

Install the Neovim plugin with your plugin manager. For lazy.nvim:

"maxpaulus43/pi-nvim"

The plugin applies its defaults automatically. Call require("pi-nvim").setup() only when you need custom options.

Install the Pi package globally:

pi install npm:@maxpaulus/pi-nvim

Restart any running Pi instances after installation. pi list should show the package.

Configuration

require("pi-nvim").setup({
  mapping = "<leader>ai",
  context_lines = 20,
  split = "botright split",
  pi_command = { "pi" },
  socket_timeout_ms = 1500,
})

The mapping works in normal and visual mode. Context contains the working directory, absolute buffer path, filetype, cursor, modified state, and numbered source lines. A modified file buffer is written before context is captured. If it cannot be written, the prompt is not sent.

The Pi extension reports successful edit and write calls back to Neovim over a local Unix socket. Neovim reloads a matching buffer only when it has no newer unsaved changes; otherwise it preserves the buffer and shows a warning.

Multiple Pi instances

When multiple Pi instances are available, Neovim shows an instance picker. Instances whose working directory exactly matches Neovim's current working directory appear first, followed by the most recently opened sessions. The preferred instance is initially highlighted. Unreachable instances are skipped during delivery.

Security

The extension creates its runtime directory with mode 0700 and its socket and metadata with mode 0600. The extension accepts only a versioned JSON message containing the prompt and limits requests to 256 KiB. Like all Pi extensions, it runs with the user's permissions; review it before installation.

Development

For local testing, install the repository as both a Neovim plugin and a Pi package:

{ dir = "/path/to/pi-nvim" }
pi install /path/to/pi-nvim

For a one-off Pi test without installing the extension:

pi -e ./pi-extension/index.ts

Run the Lua tests:

nvim --headless -u tests/minimal_init.lua -l tests/test.lua

Check that Pi can load the extension without starting a conversation:

PI_OFFLINE=1 pi -e ./pi-extension/index.ts --list-models