Skip to content

Commit

Permalink
Merge pull request #104 from equalsraf/tb-neovim
Browse files Browse the repository at this point in the history
Fix neovim support
  • Loading branch information
dbarnett authored Aug 29, 2016
2 parents 969daf2 + 5479702 commit 8191221
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
matrix:
- CI_TARGET=pytests
- CI_TARGET=vim
- CI_TARGET=neovim VROOM_ARGS=--neovim
- CI_TARGET=neovim VROOM_ARGS="--neovim --skip messages.vroom directives.vroom system.vroom"
matrix:
fast_finish: true
allow_failures:
Expand Down
8 changes: 2 additions & 6 deletions scripts/shell.vroomfaker
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ try:
with open(controlfile, 'rb') as f:
controls = pickle.load(f)

if os.getenv('VROOM_NEOVIM'):
# Neovim does not wrap commands, just pass then unchanged
command, rebuild = (sys.argv[2], lambda cmd: cmd)
else:
# Parse the user command out from vim's gibberish.
command, rebuild = vroom.vim.SplitCommand(sys.argv[2])
# Parse the user command out from vim's gibberish.
command, rebuild = vroom.vim.SplitCommand(sys.argv[2])
logs.append(vroom.test.Received(command))
handled = False

Expand Down
14 changes: 4 additions & 10 deletions vroom/neovim_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ def __init__(self, args, env, writer):
'-c', 'set shell=' + args.shell,
'-c', 'source %s' % CONFIGFILE]
env['NVIM_LISTEN_ADDRESS'] = args.servername
# Set environment for shell.vroomfaker to know Neovim is being used
env['VROOM_NEOVIM'] = '1'
self.env = env
self._cache = {}

Expand All @@ -37,11 +35,7 @@ def Start(self):
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())
self.nvim = neovim.attach('socket', path=self.args.servername)

def Communicate(self, command, extra_delay=0):
"""Sends a command to Neovim.
Expand All @@ -68,7 +62,7 @@ def Ask(self, expression):
Returns:
Return value from vim.
"""
return self.nvim_unicode.eval(expression)
return self.nvim.eval(expression)

def GetBufferLines(self, number):
"""Gets the lines in the requested buffer.
Expand All @@ -82,9 +76,9 @@ def GetBufferLines(self, number):
"""
if number not in self._cache:
if number is None:
buf = self.nvim_unicode.current.buffer
buf = self.nvim.current.buffer
else:
for b in self.nvim_unicode.buffers:
for b in self.nvim.buffers:
if b.number == number:
buf = b
break
Expand Down

0 comments on commit 8191221

Please sign in to comment.