You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also works as a library for connecting to and scripting Nvim processes through its msgpack-rpc API.
7
+
Implements support for python plugins in Nvim. Also works as a library for
8
+
connecting to and scripting Nvim processes through its msgpack-rpc API.
9
9
10
10
#### Installation
11
11
12
12
```sh
13
13
pip install neovim
14
14
```
15
15
16
-
You can install the package without being root by adding the `--user` flag. You can use `pip2` and `pip3` to explicitly install for python2 and python3, respectively.
16
+
You can install the package without being root by adding the `--user` flag. You
17
+
can use `pip2` and `pip3` to explicitly install for python2 and python3,
18
+
respectively.
17
19
18
20
#### Python Plugin API
19
21
20
-
Neovim has a new mechanism for defining plugins, as well as a number of extensions to the python API. The API extensions are accessible no matter if the traditional `:python` interface or the new mechanism is used, as discussed below.
22
+
Neovim has a new mechanism for defining plugins, as well as a number of
23
+
extensions to the python API. The API extensions are accessible no matter if the
24
+
traditional `:python` interface or the new mechanism is used, as discussed
25
+
below.
21
26
22
-
*`vim.funcs` exposes vimscript functions (both builtin and global user defined functions) as a python namespace. For instance to set the value of the value of a register
27
+
*`vim.funcs` exposes vimscript functions (both builtin and global user defined
28
+
functions) as a python namespace. For instance to set the value of the value
29
+
of a register
23
30
24
31
`vim.funcs.setreg('0', ["some", "text"], 'l')`
25
32
26
-
* 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 some execution that shouldn't block nvim.
33
+
* The API is not thread-safe in general. However, `vim.async_call` allows a
34
+
spawned thread to schedule code to be executed on the main thread. This method
35
+
could also be called from `:python` or a synchronous request handler, to defer
36
+
some execution that shouldn't block nvim.
27
37
28
38
`:python vim.async_call(myfunc, args...)`
29
39
30
-
Note that this code will still block the plugin host if it does long-running computations. Intensive computations should be done in a separate thread (or process), and `vim.async_call` can be used to send results back to nvim.
40
+
Note that this code will still block the plugin host if it does long-running
41
+
computations. Intensive computations should be done in a separate thread (or
42
+
process), and `vim.async_call` can be used to send results back to nvim.
31
43
32
-
* Some methods accept an extra keyword-only argument `async`: `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.
44
+
* Some methods accept an extra keyword-only argument `async`: `vim.eval`,
45
+
`vim.command` as well as the `vim.funcs` wrappers. The python host will not
46
+
wait for nvim to complete the request, which also means that the return value
47
+
is unavailable.
33
48
34
49
#### Remote (new-style) plugins
35
50
36
-
Neovim allows python plugins to be defined by placing python files or packages in `rplugin/python3/` (in a runtimepath folder). These follow the structure of this example:
51
+
Neovim allows python plugins to be defined by placing python files or packages
52
+
in `rplugin/python3/` (in a runtimepath folder). These follow the structure of
53
+
this example:
54
+
37
55
```python
38
56
import neovim
39
57
@@ -57,20 +75,24 @@ class TestPlugin(object):
57
75
self.nvim.out_write("testplugin is in "+ filename +"\n")
58
76
```
59
77
60
-
If `sync=True` is supplied nvim will wait for the handler to finish (this is required for function return values),
61
-
but by default handlers are executed asynchronously.
78
+
If `sync=True` is supplied nvim will wait for the handler to finish (this is
79
+
required for function return values), but by default handlers are executed
80
+
asynchronously.
62
81
63
-
You need to run `:UpdateRemotePlugins` in nvim for changes in the specifications to have effect. For details see `:help remote-plugin` in nvim.
82
+
You need to run `:UpdateRemotePlugins` in nvim for changes in the specifications
83
+
to have effect. For details see `:help remote-plugin` in nvim.
64
84
65
85
#### Development
66
86
67
-
Install the master version by cloning this repository and in the root folder execute
87
+
Install the master version by cloning this repository and in the root directory
88
+
execute
68
89
69
90
```sh
70
91
pip install .
71
92
```
72
93
73
-
You need to rerun this command if you have changed the code, in order for nvim to use it for the plugin host.
94
+
You need to rerun this command if you have changed the code, in order for nvim
95
+
to use it for the plugin host.
74
96
75
97
To run the tests execute
76
98
@@ -86,20 +108,21 @@ xterm -e "nvim -u NONE"&
86
108
nosetests
87
109
```
88
110
89
-
But note you need to restart nvim every time you run the tests! Substitute your favorite terminal emulator for `xterm`.
111
+
But note you need to restart nvim every time you run the tests! Substitute your
112
+
favorite terminal emulator for `xterm`.
90
113
91
114
#### Usage through the python REPL
92
115
93
116
A number of different transports are supported, but the simplest way to get
94
-
started is with the python REPL. First, start Nvim with a known address (or
95
-
use the `$NVIM_LISTEN_ADDRESS` of a running instance):
117
+
started is with the python REPL. First, start Nvim with a known address (or use
118
+
the `$NVIM_LISTEN_ADDRESS` of a running instance):
96
119
97
120
```sh
98
121
$ NVIM_LISTEN_ADDRESS=/tmp/nvim nvim
99
122
```
100
123
101
-
In another terminal, connect a python REPL to Nvim (note that the API is
102
-
similar to the one exposed by the [python-vim
124
+
In another terminal, connect a python REPL to Nvim (note that the API is similar
0 commit comments