toggle-corp / alacritty-colorscheme

Change colorscheme of alacritty with ease.
Apache License 2.0
343 stars 35 forks source link

neovim detection on MacOS fails #22

Closed timhemel closed 3 years ago

timhemel commented 3 years ago

The file vim.py contains the following code:

    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
tnagorra commented 3 years ago

Thanks for reporting the bug and a way to fix it. Will include this in the next release.