aboutsummaryrefslogtreecommitdiff
path: root/runtime/plugin/osc52.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /runtime/plugin/osc52.lua
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-rahm.tar.gz
rneovim-rahm.tar.bz2
rneovim-rahm.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'runtime/plugin/osc52.lua')
-rw-r--r--runtime/plugin/osc52.lua31
1 files changed, 12 insertions, 19 deletions
diff --git a/runtime/plugin/osc52.lua b/runtime/plugin/osc52.lua
index 7ffd64342e..c7f1cbe2e3 100644
--- a/runtime/plugin/osc52.lua
+++ b/runtime/plugin/osc52.lua
@@ -6,7 +6,15 @@ for _, ui in ipairs(vim.api.nvim_list_uis()) do
end
end
-if not tty or vim.g.clipboard ~= nil or vim.o.clipboard ~= '' or not os.getenv('SSH_TTY') then
+-- Do not query when any of the following is true:
+-- * TUI is not attached
+-- * OSC 52 support is explicitly disabled via g:termfeatures
+-- * Using a badly behaved terminal
+if
+ not tty
+ or (vim.g.termfeatures ~= nil and vim.g.termfeatures.osc52 == false)
+ or vim.env.TERM_PROGRAM == 'Apple_Terminal'
+then
return
end
@@ -17,28 +25,13 @@ require('vim.termcap').query('Ms', function(cap, found, seq)
assert(cap == 'Ms')
- -- Check 'clipboard' and g:clipboard again to avoid a race condition
- if vim.o.clipboard ~= '' or vim.g.clipboard ~= nil then
- return
- end
-
-- If the terminal reports a sequence other than OSC 52 for the Ms capability
-- then ignore it. We only support OSC 52 (for now)
if not seq or not seq:match('^\027%]52') then
return
end
- local osc52 = require('vim.ui.clipboard.osc52')
-
- vim.g.clipboard = {
- name = 'OSC 52',
- copy = {
- ['+'] = osc52.copy('+'),
- ['*'] = osc52.copy('*'),
- },
- paste = {
- ['+'] = osc52.paste('+'),
- ['*'] = osc52.paste('*'),
- },
- }
+ local termfeatures = vim.g.termfeatures or {}
+ termfeatures.osc52 = true
+ vim.g.termfeatures = termfeatures
end)