diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-11-02 12:17:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-02 12:17:32 +0100 |
commit | 349fa0048b7d45875daf96eefca0da163cd3a82f (patch) | |
tree | 59f1ca33f92f617572da679a9c9b72ae0a2d209f | |
parent | 36c0ec6dd49c8c1a57eaa0b9f9d3c44792582f37 (diff) | |
parent | 3a802e3c16d2a06f455fb45901ffa6954098f853 (diff) | |
download | rneovim-349fa0048b7d45875daf96eefca0da163cd3a82f.tar.gz rneovim-349fa0048b7d45875daf96eefca0da163cd3a82f.tar.bz2 rneovim-349fa0048b7d45875daf96eefca0da163cd3a82f.zip |
Merge #5542 from mhinz/health/clipboard
CheckHealth: add clipboard check
-rw-r--r-- | runtime/autoload/health/provider.vim | 14 | ||||
-rw-r--r-- | runtime/autoload/provider/clipboard.vim | 73 |
2 files changed, 59 insertions, 28 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index d4b2f07a17..3c40e48b2e 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -45,6 +45,19 @@ function! s:download(url) abort return 'missing `curl` and `python`, cannot make pypi request' endfunction +" Check for clipboard tools. +function! s:check_clipboard() abort + call health#report_start('Clipboard') + + let clipboard_tool = provider#clipboard#Executable() + if empty(clipboard_tool) + call health#report_warn( + \ "No clipboard tool found. Using the system clipboard won't work.", + \ ['See ":help clipboard"']) + else + call health#report_ok('Clipboard tool found: '. clipboard_tool) + endif +endfunction " Get the latest Neovim Python client version from PyPI. function! s:latest_pypi_version() abort @@ -371,6 +384,7 @@ function! s:check_ruby() abort endfunction function! health#provider#check() abort + call s:check_clipboard() call s:check_python(2) call s:check_python(3) call s:check_ruby() diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 0f4aa78ddd..f63ad5730b 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -31,34 +31,51 @@ function! s:try_cmd(cmd, ...) endfunction let s:cache_enabled = 1 -if executable('pbcopy') - let s:copy['+'] = 'pbcopy' - let s:paste['+'] = 'pbpaste' - let s:copy['*'] = s:copy['+'] - let s:paste['*'] = s:paste['+'] - let s:cache_enabled = 0 -elseif exists('$DISPLAY') && executable('xsel') - 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' -elseif exists('$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' -elseif executable('lemonade') - let s:copy['+'] = 'lemonade copy' - let s:paste['+'] = 'lemonade paste' - let s:copy['*'] = 'lemonade copy' - let s:paste['*'] = 'lemonade paste' -elseif executable('doitclient') - let s:copy['+'] = 'doitclient wclip' - let s:paste['+'] = 'doitclient wclip -r' - let s:copy['*'] = s:copy['+'] - let s:paste['*'] = s:paste['+'] -else - echom 'clipboard: No clipboard tool available. See :help clipboard' +let s:err = '' + +function! provider#clipboard#Error() abort + return s:err +endfunction + +function! provider#clipboard#Executable() abort + if executable('pbcopy') + 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 exists('$DISPLAY') && executable('xsel') + 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 exists('$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 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' + endif + + let s:err = 'clipboard: No clipboard tool available. See :help clipboard' + return '' +endfunction + +if empty(provider#clipboard#Executable()) finish endif |