From 2ffb8e6ee6d2d678d0c06b0f36eae468675f6750 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 12 Feb 2023 12:36:50 +0100 Subject: [PATCH] home: vim: add 'nvim-osc52' I do get the message when copying into the clipboard while ssh-ing. But trying to paste from my system clipboard shows that it did *not* get copied. This seems to only happen inside tmux. However tmux itself *does* copy to the clipboard correctly through OSC52. --- home/vim/default.nix | 1 + home/vim/plugin/settings/ssh.lua | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 home/vim/plugin/settings/ssh.lua diff --git a/home/vim/default.nix b/home/vim/default.nix index a97472e..abd185e 100644 --- a/home/vim/default.nix +++ b/home/vim/default.nix @@ -60,6 +60,7 @@ in # General enhancements vim-qf # Better quick-fix list + nvim-osc52 # Send clipboard data through terminal escape for SSH # Other wrappers git-messenger-vim # A simple blame window diff --git a/home/vim/plugin/settings/ssh.lua b/home/vim/plugin/settings/ssh.lua new file mode 100644 index 0000000..3af7b61 --- /dev/null +++ b/home/vim/plugin/settings/ssh.lua @@ -0,0 +1,17 @@ +if not require("ambroisie.utils").is_ssh() then + return +end + +local function copy(lines, _) + require('osc52').copy(table.concat(lines, '\n')) +end + +local function paste() + return {vim.fn.split(vim.fn.getreg(''), '\n'), vim.fn.getregtype('')} +end + +vim.g.clipboard = { + name = 'osc52', + copy = {['+'] = copy, ['*'] = copy}, + paste = {['+'] = paste, ['*'] = paste}, +}