diff options
author | Rui Abreu Ferreira <raf-ep@gmx.com> | 2018-12-01 15:30:50 +0000 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-12-03 00:07:08 +0100 |
commit | 07ad5d71ab97a84dc9c59b3507bf7898040d24cf (patch) | |
tree | a924fb4043499daf3686adb44b6684448906cabd /runtime/doc/provider.txt | |
parent | b19403e73e515786d2fcdb23674e3e29e62857b1 (diff) | |
download | rneovim-07ad5d71ab97a84dc9c59b3507bf7898040d24cf.tar.gz rneovim-07ad5d71ab97a84dc9c59b3507bf7898040d24cf.tar.bz2 rneovim-07ad5d71ab97a84dc9c59b3507bf7898040d24cf.zip |
clipboard: Support custom VimL functions #9304
Up to now g:clipboard["copy"] only supported string values invoked as
system commands.
This commit enables the use of VimL functions instead. The function
signatures are the same as in provider/clipboard.vim. A clipboard
provider is expected to store and return a list of lines (i.e. the text)
and a register type (as seen in setreg()).
cache_enabled is ignored if "copy" is provided by a VimL function.
Diffstat (limited to 'runtime/doc/provider.txt')
-rw-r--r-- | runtime/doc/provider.txt | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt index 4de411a60e..930c73d06e 100644 --- a/runtime/doc/provider.txt +++ b/runtime/doc/provider.txt @@ -160,7 +160,9 @@ registers. Nvim looks for these clipboard tools, in order of priority: - tmux (if $TMUX is set) *g:clipboard* -To configure a custom clipboard tool, set `g:clipboard` to a dictionary: > +To configure a custom clipboard tool, set g:clipboard to a dictionary. +For example this configuration integrates the tmux clipboard: > + let g:clipboard = { \ 'name': 'myClipboard', \ 'copy': { @@ -174,9 +176,28 @@ To configure a custom clipboard tool, set `g:clipboard` to a dictionary: > \ 'cache_enabled': 1, \ } -If `cache_enabled` is |TRUE| then when a selection is copied, Nvim will cache +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. +process has not died the cached selection is applied. + +g:clipboard can also use functions (see |lambda|) instead of strings. +For example this configuration uses the g:foo variable as a fake clipboard: > + + let g:clipboard = { + \ 'name': 'myClipboard', + \ 'copy': { + \ '+': {lines, regtype -> extend(g:, {'foo': [lines, regtype]}) }, + \ '*': {lines, regtype -> extend(g:, {'foo': [lines, regtype]}) }, + \ }, + \ 'paste': { + \ '+': {-> get(g:, 'foo', [])}, + \ '*': {-> get(g:, 'foo', [])}, + \ }, + \ } + +The "copy" function stores a list of lines and the register type. The "paste" +function returns the clipboard as a `[lines, regtype]` list, where `lines` is +a list of lines and `regtype` is a register type conforming to |setreg()|. ============================================================================== X11 selection mechanism *clipboard-x11* *x11-selection* |