Allow "nvr --remote-wait" from :terminal

This requires $NVIM_TERMINAL to be set. Put this in your vimrc:

    if has('nvim')
      let $NVIM_TERMINAL = 1
    endif

References #13
pull/20/head
Marco Hinz 8 years ago
parent be3b77fb95
commit ae6438c2ea

@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
### Added
- Now it's possible to use `nvr --remote-wait` from within `:terminal`, without
blocking until the nvim process ends, as long as `$NVIM_TERMINAL` is set. In
that case, nvr will wait until the buffers opened via `--remote-wait` (or one
of the other wait flags) get deleted before returning.
## [1.2] - 2016-06-07
### Added

@ -72,25 +72,52 @@ class Neovim():
def _execute_remotely(self, arguments, cmd, wait):
c = None
in_term = os.environ.get('NVIM_TERMINAL')
for fname in reversed(arguments):
if fname.startswith('+'):
c = fname[1:]
continue
self.server.command('{} {}'.format(cmd, prepare_filename(fname)))
if wait and in_term:
self.server.command('augroup nvr')
self.server.command('autocmd BufDelete <buffer> silent! call rpcnotify({}, "BufDelete")'.format(self.server.channel_id))
self.server.command('augroup END')
if c:
self.server.command(c)
if wait:
self._wait_until_exiting()
def _wait_until_exiting(self):
def notification_cb(name, _args):
if name == 'exiting':
self.server.stop_loop()
def setup_cb():
self.server.command('autocmd VimLeave call rpcnotify({}, "exiting")'.format(self.server.channel_id))
self.server.run_loop(None, notification_cb, setup_cb)
bufcount = len(arguments) - (1 if c else 0)
notification_cb = self._make_notification_cb(in_term, bufcount)
setup_cb = self._make_setup_cb(in_term)
self.server.run_loop(None, notification_cb, setup_cb)
def _make_setup_cb(self, in_term):
if in_term:
def setup_cb():
pass
else:
def setup_cb():
self.server.command('augroup nvr')
self.server.command('autocmd!')
self.server.command('autocmd VimLeave call rpcnotify({}, "VimLeave")'.format(self.server.channel_id))
self.server.command('augroup END')
return setup_cb
def _make_notification_cb(self, in_term, bufcount):
if in_term:
def notification_cb(msg, _args):
nonlocal bufcount
if msg == 'BufDelete':
bufcount -= 1
if bufcount == 0:
self.server.stop_loop()
self.server.command('augroup nvr')
self.server.command('autocmd!')
self.server.command('augroup END')
else:
def notification_cb(msg, _args):
if msg == 'VimLeave':
self.server.stop_loop()
return notification_cb
def _show_msg(self):
a = self.address

Loading…
Cancel
Save