Skip to content

Commit

Permalink
readme: update docs about api methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bfredl committed Oct 11, 2017
1 parent 5d40785 commit 4abd5d0
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ below.
```
vim.funcs.setreg('0', ["some", "text"], 'l')
```

* `vim.api` exposes nvim API methods. For instance to call `nvim_strwidth`,
```
result = vim.api.strwidth("some text")
```
Note the initial `nvim_` is not included. Also, object methods can be called
directly on their object,
```
buf = vim.current.buffer
len = buf.api.line_count()
```
calls `nvim_buf_line_count`. Alternatively msgpack requests can be invoked
directly,
```
result = vim.request("nvim_strwith", "some text")
len = vim.request("nvim_buf_line_count", buf)
```

* The API is not thread-safe in general. However, `vim.async_call` allows a
spawned thread to schedule code to be executed on the main thread. This method
could also be called from `:python` or a synchronous request handler, to defer
Expand All @@ -59,9 +77,9 @@ below.
process), and `vim.async_call` can be used to send results back to nvim.

* Some methods accept an `async` keyword argument: `vim.eval`,
`vim.command` as well as the `vim.funcs` wrappers. The python host will not
wait for nvim to complete the request (which also means that the return value
is unavailable).
`vim.command`, `vim.request` as well as the `vim.funcs` and `vim.api` wrappers.
The python host will not wait for nvim to complete the request (which also
means that the return value is unavailable).

#### Remote (new-style) plugins

Expand Down

0 comments on commit 4abd5d0

Please sign in to comment.