ojroques / nvim-osc52

A Neovim plugin to copy text through SSH with OSC52
BSD 2-Clause "Simplified" License
346 stars 12 forks source link

Have to evaluate init.lua twice for the osc52 settings to take effect in nvim 0.10 #39

Closed lispercat closed 2 months ago

lispercat commented 2 months ago

Strange, it only started to happen lately, maybe some lazy nvim plugins get in the way. I have following lines in my init.lua

vim.opt.clipboard = "unnamedplus" 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 }, }

So normally when I yank lines in a buffer they automatically get copies to the clipboard.

Now when I start nvim the osc52 doesn't work, so I need to evaluate init.lua for the second time, then it starts to work. On the other hand require('osc52').copy(text) functionality is there from the first nvim load.

I wonder if you may have some idea what may get in the way of that.

lispercat commented 2 months ago

Looks like I solved it by just replacing all of that config with:

vim.api.nvim_create_autocmd("TextYankPost", { callback = function() if vim.v.event.operator == "y" then local content = vim.fn.getreg('"') require("osc52").copy(content) end end, })

ojroques commented 2 months ago

Good to know!