daa84 / neovim-gtk

gtk ui for neovim
GNU General Public License v3.0
717 stars 56 forks source link

Feature request: Support for pasting the PRIMARY clipboard #14

Closed wezm closed 6 years ago

wezm commented 6 years ago

It would be nice to be able to paste the PRIMARY clipboard by pressing the middle mouse button or Shift-Insert.

wezm commented 6 years ago

I put a $20 bounty on this.

daa84 commented 6 years ago

Now toolbar button paste CLIPBOARD and middle button paste PRIMARY mode. Also fix paste in command mode. Shift-Insert not implemented as it can be binded with for example nnoremap.

wezm commented 6 years ago

Paste toolbar button is working for me but middle click only makes the mode cycle:

peek 2017-10-13 09-42

Tried middle button on mouse and laptop and both behave the same.

daa84 commented 6 years ago

Can't reproduce, does it work if just paste '' register? in insert mode this is `Ctrl+r maybe you have some custom mapping onCtrl+r` ?

daa84 commented 6 years ago

do some improvements, maybe this helps

wezm commented 6 years ago

I don't believe I have any mappings on Ctrl-r. You can see my vim config and nvim config in my dotfiles repo. I just tried the latest build on a different laptop (with the same config) and it worked!

wezm commented 6 years ago

I'll release the claim as soon as I can log into Bountysource. I'm getting an Internal server error when I try to log in at the moment.

wezm commented 6 years ago

Still can't log onto BountySource. I've pinged them on Twitter.

daa84 commented 6 years ago

I also can't log onto BountySource Thanks :+1:

wezm commented 6 years ago

I think I worked out how to trigger the behaviour in the animated GIF above. If you middle click in the space after the buffer it triggers this behaviour.

screenshot from 2017-10-18 20-50-26

I.e. if the cursor is not on the last line and I middle click in the lower part of the window with the ~ lines it cycles through the different modes shown in the GIF.

daa84 commented 6 years ago

still can't reproduce it, but found that neovim itself can process middle button 😄 , so just pass event directly to it. For me it do the same - paste from primary clipboard. maybe this helps. If there is still problems, can you check this behavior without plugins loaded.

last-partizan commented 6 years ago

What about Shift+Insert? Maybe you can let nvim process it too?

When i enter EDIT mode and press Shift-Insert, it works as expected in plain nvim, but not nvim-gtk. Also using Shift+Insert in command mode does not work, but works in plain nvim.

daa84 commented 6 years ago

Looks like gnome termnal can process Shift+Insert and pass it to nvim https://github.com/GNOME/vte/blob/be6cd8246c7993326677c9e2058deedac4263667/src/vte.cc#L5277

For gui - Shift+Insert already passed to nvim. Maybe next maps can help:

map <S-Insert>      "*gP
cmap <S-Insert>     <C-R>+
imap <S-Insert>     <C-R>+

i don't test them, but think this must work.

last-partizan commented 6 years ago

None of that bindings works.

When i press Shift+Insert in command mode, nothing happens. But when i press Shift+Del, text is inserted. So, i tried to bind and it inserts text from clipboard. Maybe Shift-Insert does not passed to gvim, and mus be handled like in gnome-terminal.

daa84 commented 6 years ago

@last-partizan yes, your right, Insert button does not passed, fixed this. Also primary clipboard is *, so update mapping a bit

map <S-Insert> "*gP
cmap <S-Insert> <C-R>*
imap <S-Insert> <C-R>*
last-partizan commented 6 years ago

Now it works! Thanks!

rbjorklin commented 6 years ago

Did you ever get scroll/middle-click to paste?

Anyhow the remap mentioned above works for Shift-Insert! Maybe mention this in the README?