Skip to content

Instantly share code, notes, and snippets.

@dhazel
Created Mar 26, 2020
Embed
What would you like to do?
Open file in neovim from terminal in same editor. Simple. Windows compatible.
alias e="remote.neovim.py"
#!c:/Python38/python.exe
#
# Hacky, but it works on Windows
#
import os
import neovim
import argparse
def isAbsolutePath(path):
return args.file.find('/') == 0
nvim = neovim.attach('socket', path=os.getenv('NVIM_LISTEN_ADDRESS'))
parser = argparse.ArgumentParser()
parser.add_argument('file', help='File to open in the existing neovim session')
args = parser.parse_args()
if isAbsolutePath(args.file):
nvim.command(f':tabnew {args.file}')
else: # relative path
nvim.command(f':tabnew {os.getcwd()}\\{args.file}')
@dhazel
Copy link
Author

dhazel commented Mar 26, 2020

This is used in the bash that comes with git on windows. It's a little hacky (leaves an error on stderr after each run) but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment