Merge #5542 from mhinz/health/clipboard

CheckHealth: add clipboard check
This commit is contained in:
Justin M. Keyes 2016-11-02 12:17:32 +01:00 committed by GitHub
commit 349fa0048b
2 changed files with 59 additions and 28 deletions

View File

@ -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()

View File

@ -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