Search code examples
neovimfish

Can I use nvim --remote to replace nvr?


I'm using neovim-remote/nvr to avoid nested instances of nvim when using the integrated terminal. This is the code:

# config.fish
if set -q NVIM
    # Avoid nested neovim instances with neovim-remote
    set -gx EDITOR "nvr --remote-wait"
    alias nvim nvr
else
    set -gx EDITOR nvim
end
set -gx VISUAL $EDITOR

It works well. A pain point is temporary files; it's why I use --remote-wait. If I don't, the program that is expecting to read the temporary file (e.g. git commits, Alt-E to edit fish's command line in $EDITOR) breaks.

This works, but I know neovim has a built-in --remote feature, and I'd like to use that to avoid the dependency. This is the configuration:

# config.fish
if set -q NVIM
    # Avoid nested neovim instances with nvim --remote
    set -gx EDITOR "nvim --server $NVIM --remote"
    alias nvim $EDITOR
else
    set -gx EDITOR nvim
end
set -gx VISUAL $EDITOR

However, this doesn't work with temporary files. For example, git complains that the message was empty and aborts the commit. Fish doesn't modify the prompt. From what I can gather, the difference is that nvr --remote-wait blocks until all buffers are deleted but nvim --remote doesn't.


Solution

  • This is currently not possible with plain neovim: https://neovim.io/doc/user/remote.html#E5600

    Vim supports additional functionality in clientserver that's not yet implemented in Nvim. In particular, none of the "wait" variants are supported yet.

    I found this issue which requests the --remote-wait feature. You could follow that to be notified of updates.