1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| function! provider#clipboard#Executable() abort if exists('g:clipboard') if type({}) isnot# type(g:clipboard) \ || type({}) isnot# type(get(g:clipboard, 'copy', v:null)) \ || type({}) isnot# type(get(g:clipboard, 'paste', v:null)) let s:err = 'clipboard: invalid g:clipboard' return '' endif
let s:copy = {} let s:copy['+'] = s:split_cmd(get(g:clipboard.copy, '+', v:null)) let s:copy['*'] = s:split_cmd(get(g:clipboard.copy, '*', v:null))
let s:paste = {} let s:paste['+'] = s:split_cmd(get(g:clipboard.paste, '+', v:null)) let s:paste['*'] = s:split_cmd(get(g:clipboard.paste, '*', v:null))
let s:cache_enabled = get(g:clipboard, 'cache_enabled', 0) return get(g:clipboard, 'name', 'g:clipboard') elseif has('mac') let s:copy['+'] = ['pbcopy'] let s:paste['+'] = ['pbpaste'] let s:copy['*'] = s:copy['+'] let s:paste['*'] = s:paste['+'] let s:cache_enabled = 0 return 'pbcopy' elseif !empty($WAYLAND_DISPLAY) && executable('wl-copy') && executable('wl-paste') let s:copy['+'] = ['wl-copy', '--foreground', '--type', 'text/plain'] let s:paste['+'] = ['wl-paste', '--no-newline'] let s:copy['*'] = ['wl-copy', '--foreground', '--primary', '--type', 'text/plain'] let s:paste['*'] = ['wl-paste', '--no-newline', '--primary'] return 'wl-copy' elseif !empty($DISPLAY) && executable('xclip') let s:copy['+'] = ['xclip', '-quiet', '-i', '-selection', 'clipboard'] let s:paste['+'] = ['xclip', '-o', '-selection', 'clipboard'] let s:copy['*'] = ['xclip', '-quiet', '-i', '-selection', 'primary'] let s:paste['*'] = ['xclip', '-o', '-selection', 'primary'] return 'xclip' elseif !empty($DISPLAY) && executable('xsel') && s:cmd_ok('xsel -o -b') let s:copy['+'] = ['xsel', '--nodetach', '-i', '-b'] let s:paste['+'] = ['xsel', '-o', '-b'] let s:copy['*'] = ['xsel', '--nodetach', '-i', '-p'] let s:paste['*'] = ['xsel', '-o', '-p'] return 'xsel' elseif executable('lemonade') let s:copy['+'] = ['lemonade', 'copy'] let s:paste['+'] = ['lemonade', 'paste'] let s:copy['*'] = ['lemonade', 'copy'] let s:paste['*'] = ['lemonade', 'paste'] return 'lemonade' elseif executable('doitclient') let s:copy['+'] = ['doitclient', 'wclip'] let s:paste['+'] = ['doitclient', 'wclip', '-r'] let s:copy['*'] = s:copy['+'] let s:paste['*'] = s:paste['+'] return 'doitclient' elseif executable('win32yank.exe') if has('wsl') && getftype(exepath('win32yank.exe')) == 'link' let win32yank = resolve(exepath('win32yank.exe')) else let win32yank = 'win32yank.exe' endif let s:copy['+'] = [win32yank, '-i', '--crlf'] let s:paste['+'] = [win32yank, '-o', '--lf'] let s:copy['*'] = s:copy['+'] let s:paste['*'] = s:paste['+'] return 'win32yank' elseif executable('termux-clipboard-set') let s:copy['+'] = ['termux-clipboard-set'] let s:paste['+'] = ['termux-clipboard-get'] let s:copy['*'] = s:copy['+'] let s:paste['*'] = s:paste['+'] return 'termux-clipboard' elseif !empty($TMUX) && executable('tmux') let s:copy['+'] = ['tmux', 'load-buffer', '-'] let s:paste['+'] = ['tmux', 'save-buffer', '-'] let s:copy['*'] = s:copy['+'] let s:paste['*'] = s:paste['+'] return 'tmux' endif
let s:err = 'clipboard: No clipboard tool. :help clipboard' return '' endfunction
|