refactor: fix nvim clipboard handling

This commit is contained in:
hhhh hgfh 2026-10-03 13:15:51 +00:00
parent a7043d885c
commit 1f70ea6edc

View file

@ -20,10 +20,15 @@ require("themes.xcodedark").setup()
-- ========== Clipboard ============= -- -- ========== Clipboard ============= --
vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd("TextYankPost", {
callback = function() callback = function()
vim.hl.hl_op({ timeout = 1000 }) vim.highlight.on_yank({ timeout = 1000 })
local contents = vim.deepcopy(vim.v.event.regcontents)
-- Preserve linewise yanks/deletes when sending plain text through OSC 52.
if vim.v.event.regtype == "V" then
table.insert(contents, "")
end
local copy_to_unnamedplus = require("vim.ui.clipboard.osc52").copy("+") local copy_to_unnamedplus = require("vim.ui.clipboard.osc52").copy("+")
copy_to_unnamedplus(vim.v.event.regcontents) copy_to_unnamedplus(contents)
local copy_to_unnamed = require("vim.ui.clipboard.osc52").copy("*") local copy_to_unnamed = require("vim.ui.clipboard.osc52").copy("*")
copy_to_unnamed(vim.v.event.regcontents) copy_to_unnamed(contents)
end, end,
}) })