Open Files with Nvim Remote

Waylon Walker - Mar 6 '22 - - Dev Community

I recently found a really great plugin by mhinz to open files in neovim from a different tmux split, without touching neovim at all.

Installation

neovim-remote is not a neovim plugin at all, it's a python cli that you can install with pip. Unlike the repo suggests, I use pipx to install nvr.

pipx install neovim-remote
Enter fullscreen mode Exit fullscreen mode

How I use it

I have this added to my .envrc that is in every one of my projects. This will tie a neovim session to that directory, and all directories under it.

export NVIM_LISTEN_ADDRESS=/tmp/nvim-$(basename $PWD)
Enter fullscreen mode Exit fullscreen mode

In my workflow I open a tmux session for each project, so this
essentially ties a neovim session to a tmux session.

Open neovim

First open neovim, but with the nvr command. This will open neovim, and look pretty much the same as always.

nvr
Enter fullscreen mode Exit fullscreen mode

If you try to run nvr again in another shell nothing will happen as its already runnin under that address, but if you give it a filename it will open the file in the first instance of neovim that you opened.

nvr readme.md
Enter fullscreen mode Exit fullscreen mode


`

Links

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .