1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-12-04 16:51:31 +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 = system('uname | tr -d "\n"') " Get platform name (stripping the trailing newline)
if s:uname == "Darwin"
"" Mac specific stuff
elseif s:uname == "linux"
"" Linux specific stuff
" Wayland clipboard fix https://github.com/vim/vim/issues/5157
xnoremap "+y :call system("wl-copy", @")<CR>
nnoremap "+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
xnoremap "*y :call system("wl-copy --primary", @")<CR>
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', '', 'g')<cr>p
"" Mac specific stuff
elseif s: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
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
"" Unkown platform
"" Unknown platform
endif
" Add shortcuts to yank/paste to unnamed/unnamedplus clipboards
noremap <Leader>y "*y
noremap <Leader>p "*p
" noremap <Leader>y "*y
" noremap <Leader>p "*p
noremap <Leader>y "+y
noremap <Leader>p "+P
noremap <Leader>Y "+y
noremap <Leader>P "+p
noremap <Leader>P "+P
" A friggin python breakpoint. Invoke with @b "FIXME: make this decent
let @b = 'A breakpoint()€ýajkj0'