folders = [f for f in listdir('/tmp') if f.startswith('nvim')]
On MacOS, there are no files in /tmp that start with nvim while nvim is running. Instead, the socket file is in /var/folders/40/[REDACTED]/T/nvimegTUh6/0. This means the script fails to detect neovim instances. This directory happens to be in the TMPDIR environment variable. The following change fixed the problem for me:
--- vim.py.orig 2021-06-07 08:19:43.000000000 +0200
+++ vim.py 2021-06-07 08:21:15.000000000 +0200
@@ -1,4 +1,4 @@
-from os import listdir
+from os import listdir, environ
from os.path import join
from pynvim import attach
@@ -14,11 +14,12 @@
def _get_all_instances():
instances = []
- folders = [f for f in listdir('/tmp') if f.startswith('nvim')]
+ tmpdir = environ.get('TMPDIR','/tmp')
+ folders = [f for f in listdir(tmpdir) if f.startswith('nvim')]
for folder in folders:
- dc = listdir(join('/tmp', folder))
+ dc = listdir(join(tmpdir, folder))
if '0' in dc:
- instances.append(join('/tmp', folder, '0'))
+ instances.append(join(tmpdir, folder, '0'))
return instances
The file
vim.py
contains the following code:On MacOS, there are no files in
/tmp
that start withnvim
while nvim is running. Instead, the socket file is in/var/folders/40/[REDACTED]/T/nvimegTUh6/0
. This means the script fails to detect neovim instances. This directory happens to be in theTMPDIR
environment variable. The following change fixed the problem for me: