From ae0b7b3aab55dd9c8a458ab5570f9480e7f5caf7 Mon Sep 17 00:00:00 2001 From: Tim Cuthbertson Date: Sat, 21 Oct 2017 19:23:14 +1100 Subject: [PATCH] don't reimplement nvr --serverlist --- VERSION | 2 +- bin/vim-watch | 23 ++++++++--------------- nix/default.nix | 3 +-- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index 1d71ef9..a2268e2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3 \ No newline at end of file +0.3.1 \ No newline at end of file diff --git a/bin/vim-watch b/bin/vim-watch index 9344e93..b65d79d 100755 --- a/bin/vim-watch +++ b/bin/vim-watch @@ -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): @@ -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): @@ -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: @@ -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 diff --git a/nix/default.nix b/nix/default.nix index 7177847..9d2843e 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -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 @@ -20,7 +20,6 @@ stdenv.mkDerivation { then '' wrapProgram $out/bin/vim-watch \ --prefix PATH : ${neovim-remote}/bin \ - --prefix PYTHONPATH : ${pythonPackages.psutil}/${python.sitePackages} \ ; '' else ""