From 1aecdb419a6364757ad691d10f153a634d07d3a2 Mon Sep 17 00:00:00 2001 From: David O'Trakoun Date: Thu, 18 Jul 2024 08:51:51 -0400 Subject: [PATCH] ssh clipboard tweaking see #580 --- nvim/after/plugin/clipboard.lua | 41 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/nvim/after/plugin/clipboard.lua b/nvim/after/plugin/clipboard.lua index 5ba58a9e..d4fc1687 100644 --- a/nvim/after/plugin/clipboard.lua +++ b/nvim/after/plugin/clipboard.lua @@ -1,29 +1,34 @@ +local smallcaps = require('dko.utils.string').smallcaps + -- neovim supports built-in osc52 as of -- https://github.com/neovim/neovim/pull/25872/files -- and it is used if we are on a remote connection by default as of -- https://github.com/neovim/neovim/pull/26064/files --- When NOT being used, prefer unnamedplus (system) clipboard +-- +-- BUT i'm gonna *force* using it and the unnamedplus if require("dko.utils.clipboard").should_use_osc52() then if vim.g.clipboard then -- already using a plugin? return end - -- else it should automatically use OSC 52 according to :h clipboard-osc52 - -- BUT for docker exec shells we need to manually enable - -- Not working - -- if require("dko.utils.vte").is_docker_exec() then - -- vim.g.clipboard = { - -- name = "OSC 52 (docker)", - -- copy = { - -- ["+"] = require("vim.ui.clipboard.osc52").copy("+"), - -- ["*"] = require("vim.ui.clipboard.osc52").copy("*"), - -- }, - -- paste = { - -- ["+"] = require("vim.ui.clipboard.osc52").paste("+"), - -- ["*"] = require("vim.ui.clipboard.osc52").paste("*"), - -- }, - -- } - -- end -else + + local tag = vim.env.SSH_TTY and " (" ..smallcaps("ssh")..")" or "" + + -- neovim automatically does this as long as 'clipboard' is not set + vim.g.clipboard = { + name = (smallcaps("osc") .. "52%s"):format(tag), + copy = { + ["+"] = require("vim.ui.clipboard.osc52").copy("+"), + ["*"] = require("vim.ui.clipboard.osc52").copy("*"), + }, + -- wezterm no paste support yet + -- https://github.com/wez/wezterm/issues/2050 + -- paste = { + -- ["+"] = require("vim.ui.clipboard.osc52").paste("+"), + -- ["*"] = require("vim.ui.clipboard.osc52").paste("*"), + -- }, + } + + -- add this now vim.o.clipboard = "unnamedplus" end