mhinz / neovim-remote

:ok_hand: Support for --remote and friends.
MIT License
1.75k stars 83 forks source link

Added option to read from stdin into a neovim register. #106

Closed oschoudhury closed 5 years ago

oschoudhury commented 5 years ago

I've added an option -r which will read from stdin into a neovim register, similarly to xclip. The benefit here is that it is added directly into a (un)named register.

Examples

echo 41 | nvr -r a
echo 42 | nvr -r
echo 43 | nvr -r '*'
echo 44 | nvr -r '+'

The first line puts "41\n" into the named register a, the second line puts "42\n" into the unnamed register. Access to the x11 clipboard is a bonus.

It is possible to extend this functionality and provide a read-register option. That way one would have access to the dozens of registers outside the terminal environment instead of 1 or 2 system clipboards.

oschoudhury commented 5 years ago

A simple demo of the --getreg option. Let's say you have a file and yank the following lines in registers a, s, d, and f.

python
-c
import os;
os.system('echo 42')

Inside a shell, you can then run

$(nvr --getreg a) $(nvr --getreg s) "$(nvr --getreg d) $(nvr --getreg f)"

and it returns 42.

mhinz commented 5 years ago

Okay, I put some more thought into this and decided against merging the PR.

It's easy to add new features that improve a certain workflow. But it would only be used by a very small share of the users. (Maybe only you. ;-)).

And yes, there is the "issue" of follow-up requests for this (and related) features.

IMHO, nvr should not add more nvr-specific features but be as compatible to the Vim options as possible. That's one of the two main scopes after all.

Moreover, it's easy enough to emulate this via:

$ echo foo | nvr -c 'silent delete r' -

and

$ nvr --remote-expr 'trim(getreg("r"))'

.oO(We should introduce a general --nvr-script option that takes any *.vim file and executes it in the remote instance. Then everyone can go wild.)

So, no hard feelings 🙏 , but I'm closing this. Nevertheless, thanks for taking the time.