1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-12-22 13:31:40 +01:00

vim: cleanup wayland copy/paste

This commit is contained in:
bretello 2023-09-14 13:07:36 +02:00
parent 24fc7dd2ed
commit 323542a705
Signed by: brethil
GPG Key ID: 876AAC6290170FE7

View File

@ -126,20 +126,9 @@ if g:uname ==? 'Darwin'
"" Mac specific stuff
elseif g:uname ==? 'Linux'
"" Linux specific stuff
function! s:WaylandYank()
if v:event['regname'] ==# '+' || (v:event['regname'] ==# 'w' && s:plus_to_w)
call system('wl-copy', getreg(v:event['regname']))
endif
endfunction
" run s:WaylandYank() after every time text is yanked
augroup waylandyank
autocmd!
autocmd TextYankPost * call s:WaylandYank()
augroup END
xnoremap "+y y:call system("wl-copy", @")<cr>
map "+p :<C-U>let @"=substitute(system('wl-paste --no-newline'), '<C-v><C-m>', '', 'g') \| exec 'normal! ' . v:count1 . 'p'<cr>
map "+P :<C-U>let @"=substitute(system('wl-paste --no-newline'), '<C-v><C-m>', '', 'g') \| exec 'normal! ' . v:count1 . 'P'<cr>
map "*p :<C-U>let @"=substitute(system('wl-paste --no-newline --primary'), '<C-v><C-m>', '', 'g') \| exec 'normal! ' . v:count1 . 'P'<cr>
else
"" Unknown platform
endif
@ -147,8 +136,7 @@ endif
" Add shortcuts to yank/paste to unnamed/unnamedplus clipboards
map <Leader>y "+y
map <Leader>p "+P
map <Leader>Y "+y
map <Leader>P "+P
map <Leader>P "*p
map <Leader>yp <Plug>yankstack_substitute_older_paste
map <leader>yn <Plug>yankstack_substitute_newer_paste