From 6016ac270f54fe8494ee7bedde109019edb709c5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 27 Jun 2017 12:21:53 +0200 Subject: provider/clipboard.vim: allow configuration #6030 Closes #6029 --- runtime/autoload/provider/clipboard.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index e15aa1f2bd..582895ae5e 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -47,7 +47,12 @@ function! provider#clipboard#Error() abort endfunction function! provider#clipboard#Executable() abort - if has('mac') && executable('pbcopy') + if exists('g:clipboard') + let s:copy = g:clipboard.copy + let s:paste = g:clipboard.paste + let s:cache_enabled = g:clipboard.cache_enabled + return g:clipboard.name + elseif has('mac') && executable('pbcopy') let s:copy['+'] = 'pbcopy' let s:paste['+'] = 'pbpaste' let s:copy['*'] = s:copy['+'] -- cgit From f0dafa89c2b7602cfedf0bd3409858e4c212b0a2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 28 Jun 2017 09:34:47 +0200 Subject: provider/clipboard.vim: Handle missing g:clipboard keys --- runtime/autoload/provider/clipboard.vim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 582895ae5e..a67681d28e 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -8,7 +8,7 @@ let s:paste = {} " ownership of the selection, so we know how long the cache is valid. let s:selection = { 'owner': 0, 'data': [] } -function! s:selection.on_exit(jobid, data, event) +function! s:selection.on_exit(jobid, data, event) abort " At this point this nvim instance might already have launched " a new provider instance. Don't drop ownership in this case. if self.owner == a:jobid @@ -18,7 +18,7 @@ endfunction let s:selections = { '*': s:selection, '+': copy(s:selection)} -function! s:try_cmd(cmd, ...) +function! s:try_cmd(cmd, ...) abort let argv = split(a:cmd, " ") let out = a:0 ? systemlist(argv, a:1, 1) : systemlist(argv, [''], 1) if v:shell_error @@ -34,7 +34,7 @@ function! s:try_cmd(cmd, ...) endfunction " Returns TRUE if `cmd` exits with success, else FALSE. -function! s:cmd_ok(cmd) +function! s:cmd_ok(cmd) abort call system(a:cmd) return v:shell_error == 0 endfunction @@ -48,10 +48,10 @@ endfunction function! provider#clipboard#Executable() abort if exists('g:clipboard') - let s:copy = g:clipboard.copy - let s:paste = g:clipboard.paste - let s:cache_enabled = g:clipboard.cache_enabled - return g:clipboard.name + 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) + return get(g:clipboard, 'name', 'g:clipboard') elseif has('mac') && executable('pbcopy') let s:copy['+'] = 'pbcopy' let s:paste['+'] = 'pbpaste' @@ -107,14 +107,14 @@ endif let s:clipboard = {} -function! s:clipboard.get(reg) +function! s:clipboard.get(reg) abort if s:selections[a:reg].owner > 0 return s:selections[a:reg].data end return s:try_cmd(s:paste[a:reg]) endfunction -function! s:clipboard.set(lines, regtype, reg) +function! s:clipboard.set(lines, regtype, reg) abort if a:reg == '"' call s:clipboard.set(a:lines,a:regtype,'+') if s:copy['*'] != s:copy['+'] @@ -149,6 +149,6 @@ function! s:clipboard.set(lines, regtype, reg) let selection.owner = jobid endfunction -function! provider#clipboard#Call(method, args) +function! provider#clipboard#Call(method, args) abort return call(s:clipboard[a:method],a:args,s:clipboard) endfunction -- cgit From 72c38b5cd5af8599090311f8d580136feb0646f1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 15 Jul 2017 15:03:41 +0200 Subject: health.vim: validate g:clipboard Closes #7020 Also fix 'iskeyword' setting, which I fumbled in 440133e0d5d576e46bd5ffa555f6a9c534789b48 --- runtime/autoload/health.vim | 3 ++- runtime/autoload/health/provider.vim | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index 1d8cae7d19..f875c8b797 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -33,7 +33,8 @@ function! health#check(plugin_names) abort setlocal wrap breakindent setlocal filetype=markdown setlocal conceallevel=2 concealcursor=nc - setlocal keywordprg=:help iskeyword=@,48-57,_,192-255,-,# + setlocal keywordprg=:help + let &l:iskeyword='!-~,^*,^|,^",192-255' call s:enhance_syntax() if empty(healthchecks) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 31a235a397..ec20615f69 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -125,6 +125,10 @@ function! s:check_clipboard() abort call health#report_warn( \ 'No clipboard tool found. Clipboard registers 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 -- cgit