示例#1
0
 def Start(self):
     """Starts Neovim"""
     self.process = subprocess.Popen(self.start_command, env=self.env)
     start_time = time.time()
     # Wait at most 5s for the Neovim socket
     while not os.path.exists(self.args.servername) \
             and time.time() - start_time < 5:
         time.sleep(0.01)
     session = neovim.socket_session(self.args.servername)
     # We keep 2 instances of Nvim, with and without automatic
     # Unicode decoding, use the first if you need Unicode
     self.nvim = neovim.Nvim.from_session(session)
     self.nvim_unicode = self.nvim.with_hook(neovim.DecodeHook())
示例#2
0
 def __init__(self, nvim):
     """Initialize the legacy python-vim environment."""
     self.setup(nvim)
     # context where all code will run
     self.module = imp.new_module('__main__')
     nvim.script_context = self.module
     # it seems some plugins assume 'sys' is already imported, so do it now
     exec('import sys', self.module.__dict__)
     self.legacy_vim = nvim.with_hook(LegacyEvalHook())
     if IS_PYTHON3:
         self.legacy_vim = self.legacy_vim.with_hook(
             neovim.DecodeHook(
                 encoding=nvim.options['encoding'].decode('ascii')))
     sys.modules['vim'] = self.legacy_vim
示例#3
0
import sys

import neovim

from nose.tools import eq_ as eq

if 'NVIM_CHILD_ARGV' in os.environ:
    vim = neovim.attach('child',
                        argv=json.loads(os.environ['NVIM_CHILD_ARGV']))
else:
    vim = neovim.attach('socket', path=os.environ['NVIM_LISTEN_ADDRESS'])

if sys.version_info >= (3, 0):
    # For Python3 we decode binary strings as Unicode for compatibility
    # with Python2
    vim = vim.with_hook(neovim.DecodeHook())

cleanup_func = ''':function BeforeEachTest()
  set all&
  redir => groups
  silent augroup
  redir END
  for group in split(groups)
    exe 'augroup '.group
    autocmd!
    augroup END
  endfor
  autocmd!
  tabnew
  let curbufnum = eval(bufnr('%'))
  redir => buflist