Skip to content

Instantly share code, notes, and snippets.

@dhazel
Created March 26, 2020 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhazel/4858340f66e18cb7e12cd2ec8f8ca8d7 to your computer and use it in GitHub Desktop.
Save dhazel/4858340f66e18cb7e12cd2ec8f8ca8d7 to your computer and use it in GitHub Desktop.
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