nvim-miniyank
nvim-miniyank copied to clipboard
Unify startput functions by removing defer.
Instead of checking for defer
argument, check if a register was used.
As far as I understand the only reason for <Plug>(miniyank-autoput)
is to keep compatibility to with registers, e.g. to use "ap
.
To just have a universal mapping I changed miniyank#startput
to check, weather another register than the default one was used. If that is the case use that register, else use miniyank.
I think this is desirable, as I usually realize that I want a previous yank after pasting and seeing that it is a wrong one.
Please check if what I did is meaningful. I have no idea of vimscript, in particular I don't know how autocommands work. I just changed your code without any understanding. But I tried it and it seems to work like I want.
Unfortunately it can't work completely, due to limitation in nvim: we cannot distiguish ""p which should paste the "
register literally, and p
which by should paste the latest item in the yankring. (same with *
if one uses clipboard=unnamed
). But nvim can add v:regname
to make this work. In the meanwhile you can always use
noremap <silent> <expr> p miniyank#startput("p",v:register != '"')
As far as I understand the only reason for <Plug>(miniyank-autoput) is to keep compatibility to with registers, e.g. to use "ap.
Another reason is if you want p
to paste from the current instance by default. I think this should be supported.
Thanks for clearing up. I think the case ""p
can simply be handle by a noremap
:
noremap ""p p
I don't understand what you mean by your other reason
Another reason is if you want p to paste from the current instance by default. I think this should be supported.
I don't have any idea of vimscript and thus don't really know what your plug-in, or miniyank-toblock
and the like does.
No. The plugin should be invoked (if the user wants it) even with explicit register, so one can cycle if the register contents were unexpected and change the register type if one wants. So instead:
noremap <silent> <expr> p miniyank#startput("p",v:register != '"')
noremap <silent> <expr> ""p miniyank#startput("p",1)
But nvim should add v:regname
, then this plugin can add <Plug>(miniyank-flexiput)
with this behavior.
I don't understand what you mean by your other reason
It's a matter of nonintrusiveness, the user can make sure the default behavior of p
doesn't change at all, while still enable cycle
and toRegtype
. This is how I use it myself.