Skip to content

Commit

Permalink
don't reimplement nvr --serverlist
Browse files Browse the repository at this point in the history
  • Loading branch information
timbertson committed Oct 21, 2017
1 parent 90436b7 commit ae0b7b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.3
0.3.1
23 changes: 8 additions & 15 deletions bin/vim-watch
Expand Up @@ -68,7 +68,11 @@ def run(trigger, initially_dirty, clear):
if mtime == last_mtime: break

def remote_expr(exe, server, cmd):
return subprocess.Popen([exe, '--servername', server, '--remote-expr', cmd])
with open(os.devnull, 'w') as devnull:
return subprocess.Popen([exe, '--servername', server, '--remote-expr', cmd], stdout=devnull)

def server_list(exe):
return subprocess.check_output([exe, '--serverlist']).decode('utf-8').strip().splitlines()

class VimServer(object):
def __init__(self, name):
Expand All @@ -82,8 +86,7 @@ class VimServer(object):

@classmethod
def list(cls):
servernames = subprocess.check_output(['vim', '--serverlist']).decode('utf-8').strip().splitlines()
return list(map(cls, servernames))
return list(map(cls, server_list('vim')))

class NeovimServer(object):
def __init__(self, path):
Expand All @@ -104,17 +107,7 @@ class NeovimServer(object):
pass
else:
return [NeovimServer(addr)]

import psutil
euid = os.geteuid()
result = []
for proc in psutil.process_iter():
if proc.uids().effective != euid: continue
if 'nvim' not in proc.name(): continue
connections = proc.connections(kind='unix')
for connection in connections:
result.append(cls(connection.laddr))
return result
return list(map(cls, server_list('nvr')))

def vimCall(opts, cmd):
if opts.no_remote:
Expand Down Expand Up @@ -152,7 +145,7 @@ def main():
p.add_option('--clear', '-c', action='store_true', help='insert a large gap between invocations')
p.add_option('--huppy', '-s', action='store_true', help='use `huppy` to run / restart a long-running process (mnemonic: [s]erver) (http://gfxmonk.net/dist/0install/huppy.xml)')
p.add_option('--verbose', '-v', action='store_true', help='verbose')
p.add_option('--neovim' , action='store_true', help='attach to nvim instead of vim (requires nvim-remote)')
p.add_option('--neovim' , action='store_true', help='attach to nvim instead of vim (requires nvim-remote, default when $NVIM_LISTEN_ADDRESS is set)', default=('NVIM_LISTEN_ADDRESS' in os.environ))
opts, args = p.parse_args()
assert len(args) > 0

Expand Down
3 changes: 1 addition & 2 deletions nix/default.nix
Expand Up @@ -11,7 +11,7 @@ stdenv.mkDerivation {
rev = "382aea1469dc832154e7c1aaf7c43923c1973155";
sha256 = "1hxv6a14wsjbn0nncgy3nl7kw428zy3l11j415y8nmvkr73y55jn";
});
buildInputs = [ python ] ++ (if enableNeovim then [ makeWrapper neovim-remote pythonPackages.psutil ] else []);
buildInputs = [ python ] ++ (if enableNeovim then [ makeWrapper neovim-remote ] else []);
installPhase = ''
mkdir -p $out/share/vim;
cp -a ./* $out/share/vim
Expand All @@ -20,7 +20,6 @@ stdenv.mkDerivation {
then ''
wrapProgram $out/bin/vim-watch \
--prefix PATH : ${neovim-remote}/bin \
--prefix PYTHONPATH : ${pythonPackages.psutil}/${python.sitePackages} \
;
''
else ""
Expand Down

0 comments on commit ae0b7b3

Please sign in to comment.