Open a single instance of Nvim-QT

I am asking also here because the ticket with the workaround is not working to me: Can't open multiple files in a single nvim-qt.exe · Issue #469 · equalsraf/neovim-qt · GitHub

Maybe someone else has better ideas to achieve that :slight_smile:

It works fine for me on a Mac. I ran nvim-qt -- +'n *' and it loaded every file (and directory!) in the current directory into a buffer.

Is this a Windows-specific bug?

Note that when you say “it doesn’t work” usually that’s not helpful. What didn’t work? Did it only open one file? Did you get an error message?

I am on linux and I compile nvim and also nvim on my own.

In my case not work means that open a new instance as usual and not in the same also this command that you shared.

Any help? :frowning:

I cannot find anything for this.

Try this:

#!/usr/bin/env python3
import os
import sys
from pynvim import attach

if len(sys.argv) < 2:
     print("Script needs an argument")
     exit(1)

instances = [path for path in os.listdir("/tmp") if path.startswith("nvim")]
if len(instances) > 1:
     print("Multiple neovim instances running, can't decide which one 
should be used")
     exit(1)

nvim = attach("socket", path=os.path.join("/tmp", instances[0], "0"))
nvim.command("edit " + os.path.abspath(sys.argv[1]))

It’s a small script that should work on linux. It looks in tmp (where
neovim opens a unix socket) and if it only finds one, connects to it and
sends an :edit command. It should be pretty easy to extend if you need
it to do more things/be smarter about the instance it chooses to connect
to etc :).

Edit: Ah, nevermind, I completely misunderstood your problem. Sorry for the noise!

No problem the approach was interesting maybe can changed to open a new tab and used as wrapper for nvim-qt.

#!/usr/bin/env python
import os
import sys
from pynvim import attach

if len(sys.argv) < 2:
     print("Script needs an argument")
     exit(1)

instances = [path for path in os.listdir("/tmp") if path.startswith("nvim")]
if len(instances) > 1:
     print("Multiple neovim instances running, can't decide which one should be used")
     exit(1)
elif len(instances) == 0:
    os.system('/usr/local/bin/nvim-qt')
else:
    nvim = attach("socket", path=os.path.join("/tmp", instances[0], "0"))
    nvim.command("tabnew " + os.path.abspath(sys.argv[1])) 

I did a nvim-qt wrapper so if executed without a file open the GUI otherwise open a new tab with the file.

My first post was marked as spam but I don’t know why. After all I am asking for help in Neovim sharing a ticket with some information of neovim-qt

I’m not sure but maybe it’s an automated thing because of all the links
you posted in the “Plugins alternative in Lua” thread?

That was indeed the case (the system flagged multiple posts with links to the same domain in short succession). I voted to restore; not sure if that’s sufficient.

We can add a special exemption for GitHub to prevent the spam filter triggering in these situations, I also believe you’re exempt after your account reaches a certain age.