@@ -46,6 +46,24 @@ below.
4646 ```
4747 vim.funcs.setreg('0', ["some", "text"], 'l')
4848 ```
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+
4967* The API is not thread-safe in general. However, ` vim.async_call ` allows a
5068 spawned thread to schedule code to be executed on the main thread. This method
5169 could also be called from ` :python ` or a synchronous request handler, to defer
5977 process), and ` vim.async_call ` can be used to send results back to nvim.
6078
6179* 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).
6583
6684#### Remote (new-style) plugins
6785
0 commit comments