Open mkdir700 opened 1 year ago
Hello, Could you share your config and your neovim version ?
I fully used the configuration in README.MD.
I added a hotkey lvim.builtin.which_key.vmappings["y"]
, which is available after the first launch, while the y
key is not.
{
"ojroques/nvim-osc52",
config = function()
lvim.builtin.which_key.vmappings["y"] = { require("osc52").copy_visual, "Copy to clipboard(Remote)" }
local function copy()
if vim.v.event.operator == "y" and vim.v.event.regname == "+" then
require("osc52").copy_register("+")
end
end
vim.api.nvim_create_autocmd("TextYankPost", { callback = copy })
end,
}
local function copy(lines, _)
require("osc52").copy(table.concat(lines, "\n"))
end
local function paste()
return { vim.fn.split(vim.fn.getreg(""), "\n"), vim.fn.getregtype("") }
end
vim.g.clipboard = {
name = "osc52",
copy = { ["+"] = copy, ["*"] = copy },
paste = { ["+"] = paste, ["*"] = paste },
}
My preliminary judgment is that it is related to the following configuration. When I comment out the following code, it can be used normally, but there will be a "Register "+" is empty" warning when pasting.
local function copy()
if vim.v.event.operator == "y" and vim.v.event.regname == "+" then
require("osc52").copy_register("+")
end
end
vim.api.nvim_create_autocmd("TextYankPost", { callback = copy })
You have two options, try to choose only one of the two:
Either you keep that part:
"ojroques/nvim-osc52",
config = function()
lvim.builtin.which_key.vmappings["y"] = { require("osc52").copy_visual, "Copy to clipboard(Remote)" }
local function copy()
if vim.v.event.operator == "y" and vim.v.event.regname == "+" then
require("osc52").copy_register("+")
end
end
vim.api.nvim_create_autocmd("TextYankPost", { callback = copy })
end,
If I understood correctly what you're trying to achieve, y
in visual mode will copy the text as well as "+y
in normal mode. Change the '+'
to ''
in the above code so that y
will copy to clipboard in normal mode.
Or you keep that part:
local function copy(lines, _)
require("osc52").copy(table.concat(lines, "\n"))
end
local function paste()
return { vim.fn.split(vim.fn.getreg(""), "\n"), vim.fn.getregtype("") }
end
vim.g.clipboard = {
name = "osc52",
copy = { ["+"] = copy, ["*"] = copy },
paste = { ["+"] = paste, ["*"] = paste },
}
Then in normal and visual mode "+y
will copy to clipboard using the plugin and it's Neovim itself that will call the plugin.
Thank you for your reply, but it doesn't work for me.
There are three pictures about register data at different times.
"ojroques/nvim-osc52",
is the content I copied.In addition, I also found that I don't need to fully press yy
. Just pressing y
once to enter operation mode and then returning to normal mode, the copy function works normally again.
Why is the first yank after opening NVIM 0 bytes?
The video demonstrated that the first copy had 0 characters, while the second copy had 175 characters.
https://github.com/ojroques/nvim-osc52/assets/56359329/6e7a714b-2acc-4726-9111-5255d34c1481
thank you, I love this plugin.