Skip to content

Commit

Permalink
ssh clipboard tweaking see davidosomething#580
Browse files Browse the repository at this point in the history
  • Loading branch information
davidosomething authored and templeman committed Jul 18, 2024
1 parent 0337b55 commit 1aecdb4
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions nvim/after/plugin/clipboard.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1aecdb4

Please sign in to comment.