A recent PR feat(clipboard): add OSC 52 clipboard support #25872 allows Neovim v0.10 to support both copy and paste operations using OSC52.
It's trivial to implement the copy operation with Vimscript but it's quite difficult to implement the paste operation without some changes.
If I understand it correctly, Neovim basically repurposes the TermReponse event to capture the content sent from the terminal after the right paste escape chars are written to the terminal.
Is your feature request about something that is currently impossible or hard to do? Please describe the problem.
It's difficult to use the existing VIM features to support the OSC52 paste operation, esp. the part where the content from the terminal can't be easily captured and made available.
Describe the solution you'd like
Implement OSC52 copy and paste natively and provide g: options for configuration (e.g. on/off)
Describe alternatives you've considered
Use a 3rd party program, such as this one (https://github.com/theimpostor/osc) to help capture the pasted content via a call to system().
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Note: Nvim's TermResponse event is completely different from Vim's TermResponse and TermResponseAll.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
For completeness, this is the PR where Neovim repurposed TermReponse.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
This migh be a big complicated, because typically terminal escapes can occur later, even withing other events that need to be handled. I have no idea how complex setting this up.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
maybe add a new code to handle osc52 paste in TermResponseAll?
h: TermResponseAll already warns
Note that this event may be triggered halfway
executing another event, especially if file I/O,
a shell command or anything else that takes time
is involved.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Closed #14995 as completed via 1f51bbc.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
It's great to see this fixed, I'm looking forward to not have to rely on https://github.com/ojroques/vim-oscyank :). I looked at the commit that fixed this, and I'm not sure how I can enable the OSC52 clipboard in my vimrc?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Not perfect but here is what I have in my vimrc. HTH.
# paste from clipboard
if has('clipboard')
nnoremap <silent> <Leader>p "+p
nnoremap <silent> <Leader>P "+P
xnoremap <silent> <Leader>p "+p
xnoremap <silent> <Leader>P "+P
else
nnoremap <silent> <Leader>p <ScriptCmd>PasteFromClipboard("p")<CR>
nnoremap <silent> <Leader>P <ScriptCmd>PasteFromClipboard("P")<CR>
xnoremap <silent> <Leader>p <ScriptCmd>PasteFromClipboard("p")<CR>
xnoremap <silent> <Leader>P <ScriptCmd>PasteFromClipboard("P")<CR>
endif
g:pending_paste_command = ""
def PasteFromClipboard(pending_paste_command: string)
echoraw("\x1b]52;c;?\x07")
g:pending_paste_command = pending_paste_command
enddef
augroup capture_osc52_paste | autocmd!
autocmd TermResponseAll osc {
if v:termosc =~ '^\%x1b]52;c;\(.*\)\%x07$'
var b64text = substitute(v:termosc, '^\%x1b]52;c;\(.*\)\%x07$', '\1', '')
var decoded_text = b64text->base64_decode()->blob2str()->join()
setreg(v:register, decoded_text)
execute 'normal! ""' .. g:pending_paste_command
g:pending_paste_command = ""
endif
}
augroup END
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()