From 1ed769feb2a13061be69563cc42d686ac44fc441 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 11 Oct 2022 11:02:00 +0800 Subject: [PATCH] feat(clipboard): add clipboard#set function --- bundle/vim-clipboard/autoload/clipboard.vim | 8 ++++++++ docs/documentation.md | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/bundle/vim-clipboard/autoload/clipboard.vim b/bundle/vim-clipboard/autoload/clipboard.vim index b5d36792e..237107ebf 100644 --- a/bundle/vim-clipboard/autoload/clipboard.vim +++ b/bundle/vim-clipboard/autoload/clipboard.vim @@ -97,3 +97,11 @@ endfunction let [s:yank_cmd, s:paste_cmd] = s:set_command() call s:LOGGER.info('yank_cmd is:' . string(s:yank_cmd)) call s:LOGGER.info('paste_cmd is:' . string(s:paste_cmd)) + + +function! clipboard#set(yank, past) abort + let s:yank_cmd = a:yank + let s:paste_cmd = a:past + call s:LOGGER.info('yank_cmd is:' . string(s:yank_cmd)) + call s:LOGGER.info('paste_cmd is:' . string(s:paste_cmd)) +endfunction diff --git a/docs/documentation.md b/docs/documentation.md index 3ed3128e7..e6f220883 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -1255,6 +1255,22 @@ Read `:h registers` for more info about other registers. | ` P` | Paste text from system clipboard before here | | ` Y` | Copy selected text to pastebin | +To change the command of clipboard, you nned to use bootstrap after function: + +```viml +" for example, to use tmux clipboard: +function! myspacevim#after() abort + call clipboard#set('tmux load-buffer -', 'tmux save-buffer -') +endfunction +``` + +within the runtime log (`SPC h L`), the clipboard command will be displayed: + +``` +[ clipboard ] [11:00:35] [670.246] [ Info ] yank_cmd is:'tmux load-buffer -' +[ clipboard ] [11:00:35] [670.246] [ Info ] paste_cmd is:'tmux save-buffer -' +``` + The ` Y` key binding will copy selected text to a pastebin server. It requires `curl` in your `$PATH`. The default command is: