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

vim: shortcuts: fix clipboard yanking on linux

This commit is contained in:
bretello 2021-03-13 16:27:09 +01:00
parent e6953b53d9
commit 273b49776d

View File

@ -98,23 +98,34 @@ nmap <leader>zz :Goyo<CR>
let s:uname='' let s:uname=''
let s:uname = system('uname | tr -d "\n"') " Get platform name (stripping the trailing newline) let s:uname = system('uname | tr -d "\n"') " Get platform name (stripping the trailing newline)
if s:uname == "Darwin" if s:uname == "Darwin"
"" Mac specific stuff "" Mac specific stuff
elseif s:uname == "linux" elseif s:uname == "Linux"
"" Linux specific stuff "" Linux specific stuff
" Wayland clipboard fix https://github.com/vim/vim/issues/5157 function! s:WaylandYank()
xnoremap "+y :call system("wl-copy", @")<CR> if v:event['regname'] == '+' || (v:event['regname'] == 'w' && s:plus_to_w)
nnoremap "+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p call system('wl-copy', getreg(v:event['regname']))
xnoremap "*y :call system("wl-copy --primary", @")<CR> endif
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', '', 'g')<cr>p endfunction
" run s:WaylandYank() after every time text is yanked
augroup waylandyank
autocmd!
autocmd TextYankPost * call s:WaylandYank()
augroup END
nnoremap "+p :<C-U>let @"=substitute(system('wl-paste --no-newline'), '<C-v><C-m>', '', 'g') \| exec 'normal! ' . v:count1 . 'p'<cr>
nnoremap "+P :<C-U>let @"=substitute(system('wl-paste --no-newline'), '<C-v><C-m>', '', 'g') \| exec 'normal! ' . v:count1 . 'P'<cr>
else else
"" Unkown platform "" Unknown platform
endif endif
" Add shortcuts to yank/paste to unnamed/unnamedplus clipboards " Add shortcuts to yank/paste to unnamed/unnamedplus clipboards
noremap <Leader>y "*y " noremap <Leader>y "*y
noremap <Leader>p "*p " noremap <Leader>p "*p
noremap <Leader>y "+y
noremap <Leader>p "+P
noremap <Leader>Y "+y noremap <Leader>Y "+y
noremap <Leader>P "+p noremap <Leader>P "+P
" A friggin python breakpoint. Invoke with @b "FIXME: make this decent " A friggin python breakpoint. Invoke with @b "FIXME: make this decent
let @b = 'A breakpoint()€ýajkj0' let @b = 'A breakpoint()€ýajkj0'