Skip to content

Commit a565d3d

Browse files
committed
support async viml calls
1 parent 222023f commit a565d3d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

neovim/api/nvim.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,13 @@ def eval(self, string, async=False):
126126
"""Evaluate a vimscript expression."""
127127
return self._session.request('vim_eval', string, async=async)
128128

129-
def call(self, name, *args):
129+
def call(self, name, *args, **kwargs):
130130
"""Call a vimscript function."""
131-
return self._session.request('vim_call_function', name, args)
131+
for k in kwargs:
132+
if k != "async":
133+
raise TypeError(
134+
"call() got an unexpected keyword argument '{}'".format(k))
135+
return self._session.request('vim_call_function', name, args, **kwargs)
132136

133137
def strwidth(self, string):
134138
"""Return the number of display cells `string` occupies.

test/test_client_rpc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ def request_cb(name, args):
3939
def test_async_call():
4040

4141
def request_cb(name, args):
42-
vim.vars['result'] = 17
42+
if name == "test-event":
43+
vim.vars['result'] = 17
4344
vim.session.stop()
4445

4546
# this would have dead-locked if not async
46-
vim.eval('rpcrequest(%d, "test-event")' % vim.channel_id, async=True)
47+
vim.funcs.rpcrequest(vim.channel_id, "test-event", async=True)
4748
vim.session.run(request_cb, None, None)
4849
eq(vim.vars['result'], 17)
4950

0 commit comments

Comments
 (0)