I have a working prototype for some kind of linux-based neovim-app. Sole functionality is "vsplit if 'k' is pressed". It is based on tarruda's nvim-terminal-edit-py
.
It is started through start_nvim.sh
:
#!/bin/bash
NVIM_LISTEN_ADDRESS='/tmp/nvim' /usr/bin/nvim &
./myapp.py
myapp.py
is
#!/usr/bin/env python
import os, sys, time, subprocess
from neovim import attach
tf = '/tmp/nvim'
env = dict(os.environ)
env['NVIM_LISTEN_ADDRESS'] = tf
#os.execvpe("nvim", ["nvim"], env)
#subprocess.Popen(["/usr/bin/nvim"], env=env)
#subprocess.call(['/usr/bin/nvim', '&'], env=env)
nvim = attach("socket", path=tf)
def key_subscribe(key, to):
cid = nvim.channel_id
nvim.command( ('nnoremap <silent> <buffer> %s ' + ':call rpcnotify(%d, "keypress", "%s")<cr>') % (key, cid, to))
def _request_cb(*args):
pass
def _notification_cb(*args):
nvim.command('vsplit')
def _setup_cb():
key_subscribe('k', 'up')
nvim.run_loop(_request_cb, _notification_cb, _setup_cb)
How to start /usr/bin/nvim
from within myapp.py
, so that start_nvim.sh
is not necessary?
I did try various things.
Uncommenting the respective line in myapp.py
and directly executing ./myapp.py
:
execvpe
does start nvim, but if I press k
no vsplit is triggered.
Popen
and call
yield
Traceback (most recent call last):
File "./myapp.py", line 18, in <module>
nvim = attach("socket", path=tf)
...
FileNotFoundError: [Errno 2] No such file or directory
Obviously, Popen/call didn't pass /tmp/nvim
to nvim
.
:nmap k :sp<CR>
?