0

How do I use nvim --server? I'm on Windows 10 and I installed nvim with scoop. I try these commands:

> nvim --version
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

> nvim --listen ~/.nvim-cache/server.pipe

As expected, nvim launches in my command prompt window. I switch to another command prompt:

> nvim --server ~/.nvim-cache/server.pipe --remote somefile.txt

nvim launches another instance in my command prompt window instead of opening that file in the first instance. There's a flash of some garbled characters (starting with +qm+54) and then the file displays, but that happens every time I start nvim.

I've also tried using %USERPROFILE%\.nvim-cache\server.pipe and ~/server.pipe instead of ~/.nvim-cache/server.pipe. I tried editing and saving the pipe in nvim (the contents aren't modified after launching --server).

Nothing in the documentation indicates this feature is platform-specific, so what am I doing wrong?

How can I use --servername and --remote in neovim? is related, but asking about vim's clientserver feature in neovim whereas I'm trying to use nvim's version of this paradigm.

3
  • The --remote-silent support has been removed from Neovim. To have only one instance of Neovim I use the solution described in that answer Commented Jul 18 at 19:38
  • @VivianDeSmedt: --remote was added back in 2022. The nvim docs even have some nvim-specific examples which I was referencing when trying to get it working.
    – idbrii
    Commented Jul 22 at 18:28
  • --remote but not --remote-silent what I have understood is that the Neovim project focus on the server and that --remote allowd to share one server across different clients. But I understand that you are interested by the 'opposite' to get only one client. Commented Jul 23 at 6:06

1 Answer 1

0

I figured out that you can use a socket instead of a pipe to get it to work on Windows.

Unfortunately, nvim's implementation requires specifying the server address differently depending if you're starting the display or sending a file to it. That translates into requiring me to explicitly start the server before I can send files to it. But if I failed to start the server, it will open terminal with the wrong v:servername but at least I see the file.

Create as vide.bat in a folder in your $PATH:

set servername=localhost:8900

:: nvim doesn't really support --remote-silent because servers and clients are
:: launched differently.
set file=%1
if defined file (
    :: Send the file to the server.
    call nvim --server localhost:8900 --remote-silent %*
) else (
    :: Start the server.
    call neovide --maximized %* -- --listen localhost:8900 -S ~/.nvim-cache/session.vim
)

Call vide.bat once with no arguments to start your server instance. Then you can associate all your text files with vide.bat and they'll open in that instance. If you accidentally open something in vide.bat without launching the server, it opens in an nvim terminal window so you can still see the file and tell what went wrong. That nvim won't be using the server, so you'll still need to run vide.bat without arguments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.