aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload/provider/clipboard.vim
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-11-17 10:48:39 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-11-18 14:58:25 -0300
commit9b8ca92a0125520c9926ea88e88b0cc26823b6ff (patch)
tree1e16c8cf98ec34cb95290ef1cd623645db63c811 /runtime/autoload/provider/clipboard.vim
parent4af5cfb51738b6740c03bd43672057202034d2f3 (diff)
downloadrneovim-9b8ca92a0125520c9926ea88e88b0cc26823b6ff.tar.gz
rneovim-9b8ca92a0125520c9926ea88e88b0cc26823b6ff.tar.bz2
rneovim-9b8ca92a0125520c9926ea88e88b0cc26823b6ff.zip
runtime: Reimplement python/clipboard providers in vimscript
Clipboard is implemented with platform-specific shell commands, and python is implemented with the external plugin facility (rpc#* functions). The script_host.py file(legacy python-vim emulation plugin) was moved/adapted from the python client repository.
Diffstat (limited to 'runtime/autoload/provider/clipboard.vim')
-rw-r--r--runtime/autoload/provider/clipboard.vim40
1 files changed, 40 insertions, 0 deletions
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
new file mode 100644
index 0000000000..615a80ca6d
--- /dev/null
+++ b/runtime/autoload/provider/clipboard.vim
@@ -0,0 +1,40 @@
+" The clipboard provider uses shell commands to communicate with the clipboard.
+" The provider function will only be registered if one of the supported
+" commands are available.
+let s:copy = ''
+let s:paste = ''
+
+if executable('pbcopy')
+ let s:copy = 'pbcopy'
+ let s:paste = 'pbpaste'
+elseif executable('xsel')
+ let s:copy = 'xsel -i -b'
+ let s:paste = 'xsel -o -b'
+elseif executable('xclip')
+ let s:copy = 'xclip -i -selection clipboard'
+ let s:paste = 'xclip -o -selection clipboard'
+endif
+
+if s:copy == ''
+ echom 'No shell command for communicating with the clipboard found.'
+ finish
+endif
+
+let s:methods = {}
+
+function! s:ClipboardGet(...)
+ return systemlist(s:paste)
+endfunction
+
+function! s:ClipboardSet(...)
+ call systemlist(s:copy, a:1)
+endfunction
+
+let s:methods = {
+ \ 'get': function('s:ClipboardGet'),
+ \ 'set': function('s:ClipboardSet')
+ \ }
+
+function! provider#clipboard#Call(method, args)
+ return s:methods[a:method](a:args)
+endfunction