Open file in neovim from terminal in same editor. Simple. Windows compatible.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias e="remote.neovim.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.