Last active
August 29, 2015 14:24
-
-
Save AaronBPaden/e52047b63b5339ebf835 to your computer and use it in GitHub Desktop.
Run a command in the running neovim session.
This file contains hidden or 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/python2 | |
from __future__ import print_function | |
from docopt import docopt | |
from neovim import attach | |
from neovim.api import NvimError | |
import os | |
import sys | |
__doc__ = """nvim-command - Run a command in the running neovim session. | |
Usage: | |
nvim-command <command>...""" | |
if __name__ == "__main__": | |
nvim = None | |
try: | |
nvim = attach("socket", path=os.environ["NVIM_LISTEN_ADDRESS"]) | |
except KeyError: | |
print("No neovim session found.", file=sys.stderr) | |
sys.exit(1) | |
try: | |
nvim.command(" ".join(docopt(__doc__)["<command>"])) | |
except NvimError as e: | |
print(e, file=sys.stderr) | |
sys.exit(1) |
@critiqjo Sure, I did see that one. It's probably more useful for interactive use–my goal here was least surprise for scripts. You could install both, and any new features added to nvimex wont break any scripts you've written.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had tried to make the command handling "smarter": nvimex.py
(The result may be dumber!)