-
-
Save dschep/3cfeba970eeac9198f2194f0c9ce04aa to your computer and use it in GitHub Desktop.
Edit file in host Neovim instance from a :terminal buffer
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
#!/usr/bin/env python | |
"""Edit a file in the host nvim instance.""" | |
import os | |
import sys | |
from neovim import attach | |
args = sys.argv[1:] | |
addr = os.environ.get("NVIM_LISTEN_ADDRESS", None) | |
if not addr: | |
os.execvp('nvim', ['nvim'] + args) | |
nvim = attach("socket", path=addr) | |
nvim.vars['files_to_edit'] = list(reversed(args)) | |
for _ in args: | |
nvim.command('exe "split ".remove(g:files_to_edit, 0)') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment