diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:40:31 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:40:31 +0000 |
commit | 339e2d15cc26fe86988ea06468d912a46c8d6f29 (patch) | |
tree | a6167fc8fcfc6ae2dc102f57b2473858eac34063 /runtime/plugin/osc52.lua | |
parent | 067dc73729267c0262438a6fdd66e586f8496946 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-339e2d15cc26fe86988ea06468d912a46c8d6f29.tar.gz rneovim-339e2d15cc26fe86988ea06468d912a46c8d6f29.tar.bz2 rneovim-339e2d15cc26fe86988ea06468d912a46c8d6f29.zip |
Merge remote-tracking branch 'upstream/master' into fix_repeatcmdline
Diffstat (limited to 'runtime/plugin/osc52.lua')
-rw-r--r-- | runtime/plugin/osc52.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/runtime/plugin/osc52.lua b/runtime/plugin/osc52.lua new file mode 100644 index 0000000000..374b70066f --- /dev/null +++ b/runtime/plugin/osc52.lua @@ -0,0 +1,36 @@ +local tty = vim.iter(vim.api.nvim_list_uis()):any(function(ui) + return ui.chan == 1 and ui.stdout_tty +end) + +if not tty or vim.g.clipboard ~= nil or vim.o.clipboard ~= '' or not os.getenv('SSH_TTY') then + return +end + +require('vim.termcap').query('Ms', function(cap, 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: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('*'), + }, + } +end) |