2
0
mirror of https://github.com/mhinz/neovim-remote synced 2024-11-11 13:10:34 +00:00

Make "-o -" and "-O -" read from STDIN

References https://github.com/mhinz/neovim-remote/issues/28
This commit is contained in:
Marco Hinz 2016-11-28 18:04:55 +01:00
parent a435992e1f
commit 3a93776ec3
No known key found for this signature in database
GPG Key ID: 1C980A1B657B4A4F
2 changed files with 16 additions and 3 deletions

17
bin/nvr
View File

@ -56,6 +56,13 @@ class Neovim():
self._msg_shown = True
return False
def read_stdin_into_buffer(self, cmd):
self.server.command(cmd)
for line in sys.stdin:
self.server.command("call append('$', '{}')".
format(line.rstrip().replace("'", "''")))
self.server.command('silent 1delete _')
def execute(self, arguments, cmd='edit', silent=False, wait=False):
if self.is_attached(silent):
self._execute_remotely(arguments, cmd, wait)
@ -298,10 +305,16 @@ def main():
if flags.o and neovim.is_attached():
for fname in flags.o:
neovim.server.command('split {}'.format(prepare_filename(fname)))
if fname == '-':
neovim.read_stdin_into_buffer('new')
else:
neovim.server.command('split {}'.format(prepare_filename(fname)))
if flags.O and neovim.is_attached():
for fname in flags.O:
neovim.server.command('vsplit {}'.format(prepare_filename(fname)))
if fname == '-':
neovim.read_stdin_into_buffer('vnew')
else:
neovim.server.command('vsplit {}'.format(prepare_filename(fname)))
if flags.c and neovim.is_attached():
for cmd in flags.c:

View File

@ -16,7 +16,7 @@ setup(
install_requires = ['neovim'],
scripts = ['bin/nvr'],
packages = [],
version = '1.3.2',
version = '1.3.3',
license = 'MIT',
keywords = 'neovim nvim nvr remote helper',
classifiers = [