Skip to content

Commit f513983

Browse files
authored
Merge pull request #389 from justinmk/embed-headless
doc, tests: specify --headless
2 parents 8db551c + 5a329f2 commit f513983

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,17 @@ bridge](http://vimdoc.sourceforge.net/htmldoc/if_pyth.html#python-vim)):
103103
[1, 2, 3]
104104
```
105105

106-
You can embed neovim into your python application instead of binding to a
107-
running neovim instance.
106+
You can embed Neovim into your python application instead of connecting to
107+
a running Neovim instance.
108108

109109
```python
110110
>>> from pynvim import attach
111-
>>> nvim = attach('child', argv=["/bin/env", "nvim", "--embed"])
111+
>>> nvim = attach('child', argv=["/bin/env", "nvim", "--embed", "--headless"])
112112
```
113113

114-
The tests can be consulted for more examples.
114+
- The ` --headless` argument tells `nvim` not to wait for a UI to connect.
115+
- Alternatively, use `--embed` _without_ `--headless` if your client is a UI
116+
and you want `nvim` to wait for your client to `nvim_ui_attach` before
117+
continuing startup.
118+
119+
See the tests for more examples.

docs/development.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ directory added to ``sys.path``.
2626

2727
If you want to test a different version than ``nvim`` in ``$PATH`` use::
2828

29-
NVIM_CHILD_ARGV='["/path/to/nvim", "-u", "NONE", "--embed"]' pytest
29+
NVIM_CHILD_ARGV='["/path/to/nvim", "-u", "NONE", "--embed", "--headless"]' pytest
3030

3131
Alternatively, if you want to see the state of nvim, you could use::
3232

@@ -86,6 +86,6 @@ You can embed Neovim into your python application instead of binding to a runnin
8686
.. code-block:: python
8787
8888
>>> from pynvim import attach
89-
>>> nvim = attach('child', argv=["/bin/env", "nvim", "--embed"])
89+
>>> nvim = attach('child', argv=["/bin/env", "nvim", "--embed", "--headless"])
9090
9191
The tests can be consulted for more examples.

pynvim/api/nvim.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,10 @@ def replace_termcodes(self, string, from_part=False, do_lt=True,
389389
from_part, do_lt, special)
390390

391391
def out_write(self, msg, **kwargs):
392-
"""Print `msg` as a normal message."""
392+
r"""Print `msg` as a normal message.
393+
394+
The message is buffered (won't display) until linefeed ("\n").
395+
"""
393396
return self.request('nvim_out_write', msg, **kwargs)
394397

395398
def err_write(self, msg, **kwargs):

pynvim/msgpack_rpc/event_loop/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BaseEventLoop(object):
3333
named pipe.
3434
- `_connect_stdio()`: Use stdin/stdout as the connection to Nvim
3535
- `_connect_child(argv)`: Use the argument vector `argv` to spawn an
36-
embedded Nvim that has it's stdin/stdout connected to the event loop.
36+
embedded Nvim that has its stdin/stdout connected to the event loop.
3737
- `_start_reading()`: Called after any of _connect_* methods. Can be used
3838
to perform any post-connection setup or validation.
3939
- `_send(data)`: Send `data`(byte array) to Nvim. The data is only
@@ -70,7 +70,8 @@ def __init__(self, transport_type, *args):
7070
Traceback (most recent call last):
7171
...
7272
AttributeError: 'BaseEventLoop' object has no attribute '_init'
73-
>>> BaseEventLoop('child', ['nvim', '--embed', '-u', 'NONE'])
73+
>>> BaseEventLoop('child',
74+
['nvim', '--embed', '--headless', '-u', 'NONE'])
7475
Traceback (most recent call last):
7576
...
7677
AttributeError: 'BaseEventLoop' object has no attribute '_init'

test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def vim():
5757
child_argv = os.environ.get('NVIM_CHILD_ARGV')
5858
listen_address = os.environ.get('NVIM_LISTEN_ADDRESS')
5959
if child_argv is None and listen_address is None:
60-
child_argv = '["nvim", "-u", "NONE", "--embed"]'
60+
child_argv = '["nvim", "-u", "NONE", "--embed", "--headless"]'
6161

6262
if child_argv is not None:
6363
editor = pynvim.attach('child', argv=json.loads(child_argv))

test/test_vim.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def test_vars(vim):
9090

9191

9292
def test_options(vim):
93-
assert vim.options['listchars'] == 'tab:> ,trail:-,nbsp:+'
94-
vim.options['listchars'] = 'tab:xy'
95-
assert vim.options['listchars'] == 'tab:xy'
93+
assert vim.windows[0].options['listchars'] == 'tab:> ,trail:-,nbsp:+'
94+
vim.windows[0].options['listchars'] = 'tab:xy'
95+
assert vim.windows[0].options['listchars'] == 'tab:xy'
9696

9797

9898
def test_buffers(vim):

0 commit comments

Comments
 (0)