refactor: fix nvim clipboard handling
This commit is contained in:
parent
a7043d885c
commit
1f70ea6edc
1 changed files with 8 additions and 3 deletions
|
|
@ -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,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue