aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-06-28 09:34:47 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-06-28 09:42:03 +0200
commitf0dafa89c2b7602cfedf0bd3409858e4c212b0a2 (patch)
tree037706f0ae394fe9812c807689f53f0389ad5fab
parent6016ac270f54fe8494ee7bedde109019edb709c5 (diff)
downloadrneovim-f0dafa89c2b7602cfedf0bd3409858e4c212b0a2.tar.gz
rneovim-f0dafa89c2b7602cfedf0bd3409858e4c212b0a2.tar.bz2
rneovim-f0dafa89c2b7602cfedf0bd3409858e4c212b0a2.zip
provider/clipboard.vim: Handle missing g:clipboard keys
-rw-r--r--runtime/autoload/provider/clipboard.vim20
-rw-r--r--runtime/doc/provider.txt52
2 files changed, 36 insertions, 36 deletions
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
diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt
index 113f4a478e..50307ccbf3 100644
--- a/runtime/doc/provider.txt
+++ b/runtime/doc/provider.txt
@@ -116,48 +116,48 @@ To use the RVM "system" Ruby installation: >
==============================================================================
Clipboard integration *provider-clipboard* *clipboard*
-Nvim has no direct connection to the system clipboard. Instead it is
-accessible through a |provider| which transparently uses shell commands for
-communicating with the clipboard.
+Nvim has no direct connection to the system clipboard. Instead it depends on
+a |provider| which transparently uses shell commands to communicate with the
+system clipboard or any other clipboard "backend".
-Clipboard access is implicitly enabled if any of the following clipboard tools
-are found in your `$PATH`.
+To ALWAYS use the clipboard for ALL operations (instead of interacting with
+the '+' and/or '*' registers explicitly): >
+ set clipboard+=unnamedplus
+<
+See 'clipboard' for details and options.
+
+ *clipboard-tool*
+The presence of a working clipboard tool implicitly enables the '+' and '*'
+registers. Nvim looks for these clipboard tools, in order of priority:
+
+ - |g:clipboard|
+ - pbcopy/pbpaste (macOS)
- xclip
- xsel (newer alternative to xclip)
- - pbcopy/pbpaste (macOS)
- lemonade (for SSH) https://github.com/pocke/lemonade
- doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/
+ - win32yank (Windows)
+ - tmux (if $TMUX is set)
-If you would like to configure the provider: >
+ *g:clipboard*
+To configure a custom clipboard tool, set `g:clipboard` to a dictionary: >
let g:clipboard = {
\ 'name': 'myClipboard',
\ 'copy': {
- \ '+': 'copyCommand',
- \ '*': 'copyCommand',
+ \ '+': 'tmux load-buffer -',
+ \ '*': 'tmux load-buffer -',
\ },
\ 'paste': {
- \ '+': 'pasteCommand',
- \ '*': 'pasteCommand',
+ \ '+': 'tmux save-buffer -',
+ \ '*': 'tmux save-buffer -',
\ },
\ 'cache_enabled': 1,
\ }
-If the cache is enabled, then when a selection is copied and the copy command
-is executed, neovim will cache this selection until the copy command process
-dies. Then, when pasting, if the copy command process has not died, the cached
-selection is returned instead of executing the paste command.
-
-The presence of a suitable clipboard tool implicitly enables the '+' and '*'
-registers.
-
-If you want to ALWAYS use the clipboard for ALL operations (as opposed
-to interacting with the '+' and/or '*' registers explicitly), set the
-following option:
->
- set clipboard+=unnamedplus
-<
-See 'clipboard' for details and more options.
+If `cache_enabled` is |TRUE| then when a selection is copied, Nvim will cache
+the selection until the copy command process dies. When pasting, if the copy
+process has not died, the cached selection is applied.
==============================================================================
X11 selection mechanism *clipboard-x11* *x11-selection*