2015-12-16 14:43:05 +00:00
|
|
|
neovim-remote
|
|
|
|
-------------
|
2015-12-04 15:24:31 +00:00
|
|
|
|
|
|
|
Neovim was rewritten to be more modular than Vim. It comes with a fancy API that
|
|
|
|
lead to reduced code size in the core, but also obsoleted some often used
|
|
|
|
features.
|
|
|
|
|
|
|
|
One of those features is the `--remote` family of command-line arguments, which
|
|
|
|
is used to communicate with server instances.
|
|
|
|
|
2015-12-16 14:43:05 +00:00
|
|
|
But fear no more! The **nvr** helper tool emulates these *missing* arguments.
|
2015-12-04 15:24:31 +00:00
|
|
|
|
2015-12-06 14:04:50 +00:00
|
|
|
**Hint:** Technically every nvim instance is a server instance. If you want to
|
|
|
|
use an already running nvim process as the server, use `:echo v:servername` to
|
|
|
|
get the path to the unix socket used for communication. Afterwards do:
|
|
|
|
```
|
|
|
|
export NVIM_LISTEN_ADDRESS=/path/to/unix/socket
|
|
|
|
```
|
|
|
|
|
2015-12-16 14:43:05 +00:00
|
|
|
This way you can omit `--servername` in subsequent calls to **nvr**.
|
|
|
|
|
|
|
|
Since `$NVIM_LISTEN_ADDRESS` is implicitely set by each nvim instance, you can
|
|
|
|
call **nvr** from within Neovim (`:terminal`!) without specifying
|
|
|
|
`--servername` either.
|
2015-12-06 14:04:50 +00:00
|
|
|
|
2015-12-04 15:48:37 +00:00
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
|
2015-12-06 14:04:50 +00:00
|
|
|
Assuming `~/bin` is in your `$PATH`:
|
2015-12-04 15:48:37 +00:00
|
|
|
|
2015-12-16 14:43:05 +00:00
|
|
|
**1)** Install the Python provider for Neovim:
|
2015-12-05 00:09:45 +00:00
|
|
|
```
|
|
|
|
$ pip3 install neovim
|
|
|
|
```
|
|
|
|
|
|
|
|
**2a)** Using the git repo:
|
2015-12-04 15:48:37 +00:00
|
|
|
```
|
|
|
|
$ mkdir -p ~/github
|
2015-12-16 14:43:05 +00:00
|
|
|
$ git clone https://github.com/mhinz/neovim-remote.git ~/github/neovim-remote
|
|
|
|
$ ln -s ~/github/neovim-remote/nvr ~/bin/nvr
|
2015-12-04 15:48:37 +00:00
|
|
|
```
|
|
|
|
|
2015-12-05 00:09:45 +00:00
|
|
|
**2b)** Download the script directly:
|
2015-12-04 15:48:37 +00:00
|
|
|
```
|
2015-12-06 14:00:30 +00:00
|
|
|
$ # Or alternatively:
|
2015-12-16 14:43:05 +00:00
|
|
|
$ curl -Lo ~/bin/nvr https://raw.githubusercontent.com/mhinz/neovim-remote/master/nvr
|
2015-12-06 14:00:30 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
**3)**
|
|
|
|
```
|
2015-12-16 14:43:05 +00:00
|
|
|
$ chmod 700 ~/bin/nvr
|
2015-12-04 15:48:37 +00:00
|
|
|
```
|
|
|
|
|
2015-12-04 16:09:48 +00:00
|
|
|
Examples
|
|
|
|
---------
|
2015-12-04 15:24:31 +00:00
|
|
|
|
2015-12-04 16:09:48 +00:00
|
|
|
In one window, create the server instance:
|
|
|
|
```
|
2015-12-16 14:43:05 +00:00
|
|
|
$ nvr --servername /tmp/nvimsocket
|
2015-12-04 16:09:48 +00:00
|
|
|
```
|
|
|
|
In another window do this:
|
|
|
|
```shell
|
|
|
|
$ # Spares us from using --servername all the time:
|
|
|
|
$ export NVIM_LISTEN_ADDRESS=/tmp/nvimsocket
|
|
|
|
$ # Open 2 files in the server:
|
2015-12-16 14:43:05 +00:00
|
|
|
$ nvr --remote file1 --remote file2
|
2015-12-04 16:09:48 +00:00
|
|
|
$ # Send keys to the current buffer of the server:
|
|
|
|
$ # Enter insert mode, enter 'abc', and go back to normal mode again:
|
2015-12-16 14:43:05 +00:00
|
|
|
$ nvr --remote-send 'iabc<esc>'
|
2015-12-04 16:09:48 +00:00
|
|
|
$ # Evaluate any VimL expression.
|
2015-12-08 19:20:38 +00:00
|
|
|
$ # Get all listed buffers:
|
2015-12-16 14:43:05 +00:00
|
|
|
$ nvr --remote-expr "join(sort(map(filter(range(bufnr('$')), 'buflisted(v:val)'), 'bufname(v:val)')), "\""\n"\"")"
|
2015-12-06 15:27:16 +00:00
|
|
|
.config/git/config
|
|
|
|
vim/vimrc
|
|
|
|
zsh/.zprofile
|
2015-12-04 16:09:48 +00:00
|
|
|
```
|
2015-12-04 15:24:31 +00:00
|
|
|
|
|
|
|
The help shows all supported arguments:
|
|
|
|
```
|
2015-12-16 14:43:05 +00:00
|
|
|
$ nvr -h
|
|
|
|
usage: nvr [arguments]
|
2015-12-04 15:24:31 +00:00
|
|
|
|
2015-12-16 14:43:05 +00:00
|
|
|
Helper tool for nvim that provides --remote and friends.
|
2015-12-04 15:24:31 +00:00
|
|
|
|
|
|
|
optional arguments:
|
|
|
|
-h, --help show this help message and exit
|
|
|
|
--remote <file> open file in new buffer [ASYNC]
|
|
|
|
--remote-wait <file> as --remote [SYNC]
|
|
|
|
--remote-silent <file>
|
|
|
|
as --remote, but don't throw error if no server is
|
|
|
|
found [ASYNC]
|
|
|
|
--remote-wait-silent <file>
|
|
|
|
as --remote, but don't throw error if no server is
|
|
|
|
found [SYNC]
|
|
|
|
--remote-tab <file> open file in new tab [SYNC]
|
|
|
|
--remote-send <keys> send keys to server [SYNC]
|
|
|
|
--remote-expr <expr> evaluate expression and print result [SYNC]
|
|
|
|
--servername <sock> path to unix socket (overrides $NVIM_LISTEN_ADDRESS)
|
|
|
|
|
|
|
|
Happy hacking!
|
|
|
|
```
|
|
|
|
|