Skip to content

Instantly share code, notes, and snippets.

@dschep
Forked from tarruda/nvim-terminal-edit.py
Last active January 9, 2018 18:52
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 dschep/3cfeba970eeac9198f2194f0c9ce04aa to your computer and use it in GitHub Desktop.
Save dschep/3cfeba970eeac9198f2194f0c9ce04aa to your computer and use it in GitHub Desktop.
Edit file in host Neovim instance from a :terminal buffer
#!/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