aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/health.vim2
-rw-r--r--runtime/autoload/health/provider.vim12
-rw-r--r--runtime/autoload/provider/clipboard.vim20
3 files changed, 22 insertions, 12 deletions
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim
index f875c8b797..bd99a0e104 100644
--- a/runtime/autoload/health.vim
+++ b/runtime/autoload/health.vim
@@ -90,7 +90,7 @@ endfunction
" Changes ':h clipboard' to ':help |clipboard|'.
function! s:help_to_link(s) abort
- return substitute(a:s, '\v:h%[elp] ([^|][^"\r\n]+)', ':help |\1|', 'g')
+ return substitute(a:s, '\v:h%[elp] ([^|][^"\r\n ]+)', ':help |\1|', 'g')
endfunction
" Format a message for a specific report item
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index ec20615f69..26db5b77b7 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -121,14 +121,14 @@ function! s:check_clipboard() abort
call health#report_start('Clipboard (optional)')
let clipboard_tool = provider#clipboard#Executable()
- if empty(clipboard_tool)
+ if exists('g:clipboard') && empty(clipboard_tool)
+ call health#report_error(
+ \ provider#clipboard#Error(),
+ \ ["Use the example in :help g:clipboard as a template, or don't set g:clipboard at all."])
+ elseif empty(clipboard_tool)
call health#report_warn(
- \ 'No clipboard tool found. Clipboard registers will not work.',
+ \ 'No clipboard tool found. Clipboard registers (`"+` and `"*`) will not work.',
\ [':help clipboard'])
- elseif exists('g:clipboard') && (type({}) != type(g:clipboard)
- \ || !has_key(g:clipboard, 'copy') || !has_key(g:clipboard, 'paste'))
- call health#report_error(
- \ 'g:clipboard exists but is malformed. It must be a dictionary with the keys documented at :help g:clipboard')
else
call health#report_ok('Clipboard tool found: '. clipboard_tool)
endif
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index 8eb694e9fa..8fe53c495a 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -3,6 +3,7 @@
" available.
let s:copy = {}
let s:paste = {}
+let s:clipboard = {}
" When caching is enabled, store the jobid of the xclip/xsel process keeping
" ownership of the selection, so we know how long the cache is valid.
@@ -23,7 +24,7 @@ function! s:selection.on_exit(jobid, data, event) abort
call provider#clear_stderr(a:jobid)
endfunction
-let s:selections = { '*': s:selection, '+': copy(s:selection)}
+let s:selections = { '*': s:selection, '+': copy(s:selection) }
function! s:try_cmd(cmd, ...) abort
let argv = split(a:cmd, " ")
@@ -55,9 +56,15 @@ endfunction
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 = get(g:clipboard, 'copy', { '+': v:null, '*': v:null })
let s:paste = get(g:clipboard, 'paste', { '+': v:null, '*': v:null })
- let s:cache_enabled = get(g:clipboard, 'cache_enabled', 1)
+ let s:cache_enabled = get(g:clipboard, 'cache_enabled', 0)
return get(g:clipboard, 'name', 'g:clipboard')
elseif has('mac') && executable('pbcopy')
let s:copy['+'] = 'pbcopy'
@@ -104,16 +111,17 @@ function! provider#clipboard#Executable() abort
return 'tmux'
endif
- let s:err = 'clipboard: No clipboard tool available. :help clipboard'
+ let s:err = 'clipboard: No clipboard tool. :help clipboard'
return ''
endfunction
if empty(provider#clipboard#Executable())
+ " provider#clipboard#Call() *must not* be defined if the provider is broken.
+ " Otherwise eval_has_provider() thinks the clipboard provider is
+ " functioning, and eval_call_provider() will happily call it.
finish
endif
-let s:clipboard = {}
-
function! s:clipboard.get(reg) abort
if s:selections[a:reg].owner > 0
return s:selections[a:reg].data
@@ -154,7 +162,9 @@ function! s:clipboard.set(lines, regtype, reg) abort
echohl WarningMsg
echomsg 'clipboard: failed to execute: '.(s:copy[a:reg])
echohl None
+ return 0
endif
+ return 1
endfunction
function! provider#clipboard#Call(method, args) abort