Double-click any path in a tmux pane (a git status line, an rg hit, a
stack-trace frame, a ToolName(path) tool-call line, …) and it opens in the
Neovim instance running in another pane of the same window, jumping to the
right line/col when the token carries a :line[:col] suffix.
It works by giving each nvim a per-pane RPC socket, then having a tmux
double-click binding hand the clicked word to a small script that cleans it up
and sends :edit to that socket.
| File | Goes where | Purpose |
|---|---|---|
nvim-open |
~/.local/bin/nvim-open (chmod +x) |
Cleans the clicked token and forwards it to the pane's nvim via --remote-send. |
tmux.conf.snippet |
append to your tmux config | word-separators + DoubleClick1Pane binding. |
nvim-serverstart.lua |
your nvim config (e.g. lua/config/options.lua) |
Starts the per-pane socket nvim-open connects to. |
# 1. the script
install -Dm755 nvim-open ~/.local/bin/nvim-open
# 2. tmux: append the snippet, then reload
cat tmux.conf.snippet >> ~/.tmux.conf # or ~/.config/tmux/tmux.conf.local
tmux source ~/.tmux.conf
# 3. nvim: paste nvim-serverstart.lua into your config, restart nvimRequires bash, tmux, and a reasonably recent nvim (RPC --server /
--remote-send). ~/.local/bin must be on your PATH.
word-separators is set to whitespace only, so a double-click captures the
whole token (kebab-case, scoped pkgs, and the :line:col suffix stay intact).
nvim-open then:
- Strips enclosing punctuation — leading
([{<"'`and trailing)]},;>."'`. A leading./~//is preserved (.env,~/x,./foostill work). - Splits a trailing
:lineor:line:colsuffix (rg/grep/gcc/stack-trace style) to position the cursor. - Unwraps a
wrapper(path)token — a click onUpdate(~/.config/foo)or a Java frameFoo.bar(File.java:42)targets the inner path. Real paths that contain(still win: the plain token is tried first, and only a miss falls through to the unwrapped candidate. - Resolves relative paths against the clicked pane's cwd
(
NVIM_OPEN_CWD), not nvim's. - With
NVIM_OPEN_REQUIRE_EXISTING=1(set by the tmux binding) a click is a no-op unless the word resolves to a real file/dir, so double-clicking ordinary words does nothing. Runnvim-open <path>by hand (flag unset) and it'll happily open a not-yet-created file.
It finds an nvim pane with a live socket in the current window only (never
pulls you across windows/sessions), sends <C-\><C-n>:silent! edit …, then
focuses that pane. If no reusable nvim exists in the window, it just opens nvim
in place.
| Var | Set by | Effect |
|---|---|---|
NVIM_OPEN_CWD |
tmux binding | Base dir for relative paths (the clicked pane's cwd). |
NVIM_OPEN_REQUIRE_EXISTING |
tmux binding | Only act on words that resolve to a real path. |
NVIM_OPEN_FOCUS_DELAY |
optional | Seconds before re-asserting focus on the nvim pane (default 0.25). |