@@ -46,6 +46,24 @@ below.
46
46
```
47
47
vim.funcs.setreg('0', ["some", "text"], 'l')
48
48
```
49
+
50
+ * ` vim.api ` exposes nvim API methods. For instance to call ` nvim_strwidth ` ,
51
+ ```
52
+ result = vim.api.strwidth("some text")
53
+ ```
54
+ Note the initial ` nvim_ ` is not included. Also, object methods can be called
55
+ directly on their object,
56
+ ```
57
+ buf = vim.current.buffer
58
+ len = buf.api.line_count()
59
+ ```
60
+ calls ` nvim_buf_line_count ` . Alternatively msgpack requests can be invoked
61
+ directly,
62
+ ```
63
+ result = vim.request("nvim_strwith", "some text")
64
+ len = vim.request("nvim_buf_line_count", buf)
65
+ ```
66
+
49
67
* The API is not thread-safe in general. However, ` vim.async_call ` allows a
50
68
spawned thread to schedule code to be executed on the main thread. This method
51
69
could also be called from ` :python ` or a synchronous request handler, to defer
59
77
process), and ` vim.async_call ` can be used to send results back to nvim.
60
78
61
79
* Some methods accept an ` async ` keyword argument: ` vim.eval ` ,
62
- ` vim.command ` as well as the ` vim.funcs ` wrappers. The python host will not
63
- wait for nvim to complete the request (which also means that the return value
64
- is unavailable).
80
+ ` vim.command ` , ` vim.request ` as well as the ` vim.funcs ` and ` vim.api ` wrappers.
81
+ The python host will not wait for nvim to complete the request (which also
82
+ means that the return value is unavailable).
65
83
66
84
#### Remote (new-style) plugins
67
85
0 commit comments