aboutsummaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorTomek Łaziuk2015-08-17 23:18:47 +0200
committerTomek Łaziuk2015-09-02 09:53:08 +0200
commita30524a9fc3e79ae9982b5e93888ee4bc0c1f4db (patch)
treec07bab1cb3965d9c9806fbe270f6f0fd4b68790a /plugin
parent750002ade00e2b8264bb131906a605e49985d812 (diff)
downloadvim-system-copy-a30524a9fc3e79ae9982b5e93888ee4bc0c1f4db.tar.bz2
user options for copy and paste commands addedHEADmaster
in this commit: user custom options for copy and paste commands more specific and unique checks for build-in mappings checking if plugin was initialized moved to very first lines
Diffstat (limited to 'plugin')
-rw-r--r--plugin/system_copy.vim35
1 files changed, 25 insertions, 10 deletions
diff --git a/plugin/system_copy.vim b/plugin/system_copy.vim
index 2c6bc7c..d280e1e 100644
--- a/plugin/system_copy.vim
+++ b/plugin/system_copy.vim
@@ -1,3 +1,8 @@
+if exists('g:loaded_system_copy') || v:version < 700
+ finish
+endif
+let g:loaded_system_copy = 1
+
let s:blockwise = 'blockwise visual'
let s:visual = 'visual'
let s:motion = 'motion'
@@ -6,11 +11,6 @@ let s:mac = 'mac'
let s:windows = 'windows'
let s:linux = 'linux'
-if exists('g:loaded_system_copy') || &cp || v:version < 700
- finish
-endif
-let g:loaded_system_copy = 1
-
function! s:system_copy(type, ...) abort
let mode = <SID>resolve_mode(a:type, a:0)
if mode == s:linewise
@@ -21,8 +21,9 @@ function! s:system_copy(type, ...) abort
else
silent exe "normal! `[v`]y"
endif
- silent call system(s:CopyCommandForCurrentOS(), getreg('@'))
- echohl String | echon 'Copied to system clipboard via: ' . mode | echohl None
+ let command = s:CopyCommandForCurrentOS()
+ silent call system(command, getreg('@'))
+ echohl String | echon 'Copied to clipboard using: ' . command | echohl None
endfunction
function! s:system_paste() abort
@@ -59,6 +60,9 @@ function! s:currentOS()
endfunction
function! s:CopyCommandForCurrentOS()
+ if exists('g:system_copy#copy_command')
+ return g:system_copy#copy_command
+ endif
let os = <SID>currentOS()
if os == s:mac
return 'pbcopy'
@@ -70,6 +74,9 @@ function! s:CopyCommandForCurrentOS()
endfunction
function! s:PasteCommandForCurrentOS()
+ if exists('g:system_copy#paste_command')
+ return g:system_copy#paste_command
+ endif
let os = <SID>currentOS()
if os == s:mac
return 'pbpaste'
@@ -85,12 +92,20 @@ nnoremap <silent> <Plug>SystemCopy :<C-U>set opfunc=<SID>system_copy<CR>g@
nnoremap <silent> <Plug>SystemCopyLine :<C-U>set opfunc=<SID>system_copy<Bar>exe 'norm! 'v:count1.'g@_'<CR>
nnoremap <silent> <Plug>SystemPaste :<C-U>call <SID>system_paste()<CR>
-if !hasmapto('<Plug>SystemCopy') || maparg('cp','n') ==# ''
- xmap cp <Plug>SystemCopy
+if !hasmapto('<Plug>SystemCopy', 'n') || maparg('cp', 'n') ==# ''
nmap cp <Plug>SystemCopy
+endif
+
+if !hasmapto('<Plug>SystemCopy', 'v') || maparg('cp', 'v') ==# ''
+ xmap cp <Plug>SystemCopy
+endif
+
+if !hasmapto('<Plug>SystemCopyLine', 'n') || maparg('cP', 'n') ==# ''
nmap cP <Plug>SystemCopyLine
endif
-if !hasmapto('<Plug>SystemPaste') || maparg('cv','n') ==# ''
+if !hasmapto('<Plug>SystemPaste', 'n') || maparg('cv', 'n') ==# ''
nmap cv <Plug>SystemPaste
endif
+
+" vim:ts=2:sw=2:sts=2