Skip to content

Commit bc3332b

Browse files
committed
Update documentation
1 parent eeb987b commit bc3332b

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,43 @@
22

33
[![Build Status](https://travis-ci.org/neovim/python-client.svg?branch=master)](https://travis-ci.org/neovim/python-client)
44

5-
Library aims to emulate the current python-vim interface through Neovim
6-
msgpack-rpc API
5+
Library for scripting Nvim processes through it's msgpack-rpc API.
76

87
#### Installation
98

109
```sh
1110
pip install neovim
1211
```
1312

14-
#### Usage
13+
#### Usage through the python REPL
1514

16-
Start Neovim with a known address or query the value of $NVIM_LISTEN_ADDRESS
17-
after startup:
15+
A number of different transports are supported, but the simplest way to get
16+
started is with the python REPL. First, start Nvim with a known address(or
17+
query the value of $NVIM_LISTEN_ADDRESS of a running instance):
1818

1919
```sh
20-
$ NVIM_LISTEN_ADDRESS=/tmp/neovim nvim
20+
$ NVIM_LISTEN_ADDRESS=/tmp/nvim nvim
2121
```
2222

23-
Open the python REPL with another terminal connect to Neovim:
23+
Open the python REPL with another terminal connect to Nvim(Note that the API is
24+
similar to the one exposed by the [python-vim
25+
bridge](http://vimdoc.sourceforge.net/htmldoc/if_pyth.html#python-vim))
2426

2527
```python
26-
>>> import neovim
27-
>>> vim = neovim.connect('/tmp/neovim')
28-
>>> buffer = vim.buffers[0] # get the first buffer
28+
>>> from neovim import socket_session, Nvim
29+
# Create a msgpack-rpc session to the unix domain socket created by Nvim:
30+
>>> session = socket_session('/tmp/nvim')
31+
# Create a Nvim instance from the session(don't call Nvim constructor!):
32+
>>> nvim = Nvim.from_session(session)
33+
# Now do some work.
34+
>>> buffer = nvim.buffers[0] # Get the first buffer
2935
>>> buffer[0] = 'replace first line'
3036
>>> buffer[:] = ['replace whole buffer']
31-
>>> vim.command('vsplit')
32-
>>> vim.windows[1].width = 10
33-
>>> vim.vars['global_var'] = [1, 2, 3]
34-
>>> vim.eval('g:global_var')
37+
>>> nvim.command('vsplit')
38+
>>> nvim.windows[1].width = 10
39+
>>> nvim.vars['global_var'] = [1, 2, 3]
40+
>>> nvim.eval('g:global_var')
3541
[1, 2, 3]
3642
```
3743

38-
See the test subdirectory for more examples
39-
40-
This is still alpha and incomplete, use only for testing purposes
44+
The tests can be consulted for more examples.

0 commit comments

Comments
 (0)