nvimfs icon indicating copy to clipboard operation
nvimfs copied to clipboard

add tool to open file in existing nvim

Open josephholsten opened this issue 8 years ago • 0 comments

neovimfs has given me the ability to emulate plan9 acme's ability to open a file in the existing editor with a B script, here's what I'm using now:

#!/bin/sh

if [ x != x"$DEBUG" ]; then
    set -x
fi

neovimfs="$HOME/.config/nvim/neovimfs"
client="$(find "$neovimfs/clients" -depth 1| grep -v new | head -1 | xargs basename)"

fullpath="$(realpath "$1")"

if [ -z "$client" ]; then
    exec "$EDITOR" "$fullpath"
else
    escaped=$(echo "$fullpath" | sed 's/ /\\ /')
    cmd="$neovimfs/clients/$client/cmd"
    if [ ! -f "$cmd" ]; then
        echo "cmd socket '$cmd' missing" >&2
        exit 1
    fi
    echo "vsplit" > "$cmd"
    echo "e $escaped" > "$cmd"
        echo "$fullpath opened in existing editor" >&2
fi

josephholsten avatar Jan 31 '16 04:01 josephholsten