mirror of
https://github.com/neovim/neovim.git
synced 2026-01-03 01:46:31 +10:00
feat(clipboard)!: use OSC 52 as fallback clipboard provider (#31730)
We currently enable the OSC 52 clipboard provider by setting g:clipboard when a list of conditions are met, one of which is that $SSH_TTY must be set. We include this condition because often OSC 52 is not the best clipboard provider, so if there are "local" providers available Nvim should prefer those over OSC 52. However, if no other providers are available, Nvim should use OSC 52 even when $SSH_TTY is not set. When a user is in an SSH session then the checks for the other clipboard providers will still (typically) fail, so OSC 52 continues to be enabled by default in SSH sessions. This is marked as a breaking change because there are some cases where OSC 52 wasn't enabled before and is now (or vice versa).
This commit is contained in:
@@ -169,6 +169,14 @@ function! provider#clipboard#Executable() abort
|
||||
let s:copy['*'] = s:copy['+']
|
||||
let s:paste['*'] = s:paste['+']
|
||||
return 'tmux'
|
||||
elseif get(get(g:, 'termfeatures', {}), 'osc52') && &clipboard ==# ''
|
||||
" Don't use OSC 52 when 'clipboard' is set. It can be slow and cause a lot
|
||||
" of user prompts. Users can opt-in to it by setting g:clipboard manually.
|
||||
let s:copy['+'] = v:lua.require'vim.ui.clipboard.osc52'.copy('+')
|
||||
let s:copy['*'] = v:lua.require'vim.ui.clipboard.osc52'.copy('*')
|
||||
let s:paste['+'] = v:lua.require'vim.ui.clipboard.osc52'.paste('+')
|
||||
let s:paste['*'] = v:lua.require'vim.ui.clipboard.osc52'.paste('*')
|
||||
return 'OSC 52'
|
||||
endif
|
||||
|
||||
let s:err = 'clipboard: No clipboard tool. :help clipboard'
|
||||
|
||||
Reference in New Issue
Block a user