Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readme: update docs about api methods #272

Merged
merged 1 commit into from
Oct 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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