Co-op mode for Neovim

Screen-sharing works until the other person actually wants to type. Multiplayer.nvim is my take on video-game-style co-op inside Neovim: both people keep their own config, plugins, and keybindings while editing the same buffer in real time.

Instead of spinning up a hosted collaboration server, the plugin lets either editor host a session directly from the terminal.

:Coop host
:Coop join
:Coop share

When you host, the plugin copies a connection ticket straight into your clipboard (+ register). Your partner runs :Coop join, pastes the ticket, and their Neovim instance connects peer-to-peer, holding shared buffers in memory and syncing saves back to the host.

Lua inside the editor, Rust on the wire

Neovim already ships with the primitives needed to observe a buffer closely, so the plugin splits responsibilities cleanly between Lua and Rust:

  • Buffer tracking (nvim_buf_attach): The same API that powers LSP in Neovim hooks on_lines on every shared buffer, sending line diffs over vim.rpcnotify as you edit.
  • Presence & jumpable cursors: CursorMoved and CursorMovedI autocmds publish each collaborator’s position and visual selection. Remote cursors are written as native Neovim marks (nvim_buf_set_mark) and highlight namespaces, so you don’t just see where your teammate is: you can jump straight to them with a normal Vim mark.
  • Peer-to-peer transport: Lua spawns a compiled Rust comms binary via vim.uv.spawn(). Built with Iroh, Tokio, and QUIC (iroh-quinn, custom ALPN MULTIPLAYER.NVIM), it tunnels Neovim’s RPC traffic over low-latency UDP streams without port forwarding or a central server.

The hard parts

Shipping an edit across the network is the easy half. Making two editors stay coherent while both people type at once breaks down into three problems:

  1. Echo loops: Applying a remote nvim_buf_set_lines triggers on_lines locally. Tracking the originating client_number on the last applied edit keeps remote changes from bouncing right back across the wire.
  2. Concurrent edits: Naive line-range patches work cleanly when two people edit different parts of a file, but overlapping inserts, deletes, and undo trees push directly toward CRDTs or Operational Transformation.
  3. Session lifecycle: Keeping in-memory guest buffers, file saves, disconnects, and Rust sidecar cleanup (VimLeave / SIGTERM) predictable across messy real-world sessions.

Where it stands

Multiplayer.nvim is under active development, with rough edges and breaking changes documented in the repository. It has been one of my favorite playgrounds for combining Neovim internals, async Rust networking, and distributed-state tradeoffs in one project.