mhinz/neovim-remote

nvr does no take NVIM_LISTEN_ADDRESS into account

Closed this issue · 6 comments

I've ended up for the sake of robustness to do

function nvr-connect {
  export socket=`find /tmp -maxdepth 1 -name "nvim*" | head -1`
 
  if [ -z "$socket" ]; then
    echo "NeoVim is not running."
  else
    export NVIM_LISTEN_ADDRESS=$socket
  fi
}

I like this over the global name because this will always work even if NeoVim was started with a variable socket name.

But when I use as below, nvr does not respect the environment variable:

~ master
❯ nvr-connect 

~ master
❯ echo $NVIM_LISTEN_ADDRESS
/tmp/nvimIaEski

I.e. it creates a new NeoVim instance instead of opening the file in $NVIM_LISTEN_ADDRESS pointed NeoVim.

$NVIM_LISTEN_ADDRESS is deprecated in NeoVim

https://neovim.io/doc/user/deprecated.html

image

Could that be updated in the Readme, since I had the same issues and spend quite a lot of time to get nvr working in neovim.
Also, even armed with that knowledge, it still can't get it to work in neovim, i.e.:
nvim --listen /tmp/nvimsocket followed by :echo v:servername gives me a temp file instead of nvimsocket (e.g. /tmp/nvimgLlrnE/0

Is there any solution?

Edit: neovim will open a socket by detfault when it starts, which you can query by using nvr --serverlist and then connect to it with nvr --servername </tmp/nvimXXXXX> file1.txt. Alternatively you can follow what I originally suggested about using TCP, but be mindful of the security implications.


It seems to work fine if you just start neovim with nvim --listen localhost then you can use nvr --servername localhost file1.txt.

Could that be updated in the Readme, since I had the same issues and spend quite a lot of time to get nvr working in neovim. Also, even armed with that knowledge, it still can't get it to work in neovim, i.e.: nvim --listen /tmp/nvimsocket followed by :echo v:servername gives me a temp file instead of nvimsocket (e.g. /tmp/nvimgLlrnE/0

The same here!

mhinz commented

As of nvim 0.7, nvim --listen foo should be preferred over setting $NVIM_LISTEN_ADDRESS before starting nvim. The latter still works, but is considered obsolete.

Since people use it in scripts, nvr will continue supporting $NVIM_LISTEN_ADDRESS.

I'll update the README and the message given for nvr --nostart accordingly.