diff --git a/nvim/init.lua b/nvim/init.lua index 5f6b52d..8200ba6 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -20,10 +20,15 @@ require("themes.xcodedark").setup() -- ========== Clipboard ============= -- vim.api.nvim_create_autocmd("TextYankPost", { 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("+") - copy_to_unnamedplus(vim.v.event.regcontents) + copy_to_unnamedplus(contents) local copy_to_unnamed = require("vim.ui.clipboard.osc52").copy("*") - copy_to_unnamed(vim.v.event.regcontents) + copy_to_unnamed(contents) end, })