Skip to content

Commit 1e2e204

Browse files
committed
doc: mention request(...,async)
1 parent 54e1097 commit 1e2e204

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,32 @@ below.
4343

4444
* `vim.funcs` exposes vimscript functions (both builtin and global user defined
4545
functions) as a python namespace. For instance to set the value of a register
46-
47-
`vim.funcs.setreg('0', ["some", "text"], 'l')`
48-
46+
```
47+
vim.funcs.setreg('0', ["some", "text"], 'l')
48+
```
4949
* The API is not thread-safe in general. However, `vim.async_call` allows a
5050
spawned thread to schedule code to be executed on the main thread. This method
5151
could also be called from `:python` or a synchronous request handler, to defer
5252
some execution that shouldn't block nvim.
53+
```
54+
:python vim.async_call(myfunc, args...)
5355
54-
`:python vim.async_call(myfunc, args...)`
55-
56+
```
5657
Note that this code will still block the plugin host if it does long-running
5758
computations. Intensive computations should be done in a separate thread (or
5859
process), and `vim.async_call` can be used to send results back to nvim.
5960

60-
* Some methods accept an extra keyword-only argument `async`: `vim.eval`,
61+
* Some methods accept an `async` parameter: `vim.eval`,
6162
`vim.command` as well as the `vim.funcs` wrappers. The python host will not
62-
wait for nvim to complete the request, which also means that the return value
63-
is unavailable.
63+
wait for nvim to complete the request (which also means that the return value
64+
is unavailable).
65+
66+
* You can publish arbitrary events (msgpack **notification** messages) by
67+
passing `async=True` to `vim.request()` (this is analogous to the VimL
68+
`rpcnotify()` function).
69+
```
70+
vim.request("my_event", "arg1", "arg2", async=True)
71+
```
6472

6573
#### Remote (new-style) plugins
6674

0 commit comments

Comments
 (0)