Giter Site home page Giter Site logo

Comments (5)

ojroques avatar ojroques commented on June 14, 2024

Hello,
Could you share your config and your neovim version ?

from nvim-osc52.

mkdir700 avatar mkdir700 commented on June 14, 2024

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 },
	}

from nvim-osc52.

mkdir700 avatar mkdir700 commented on June 14, 2024

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 })

from nvim-osc52.

ojroques avatar ojroques commented on June 14, 2024

You have two options, try to choose only one of the two:

  1. 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.

  1. 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.

from nvim-osc52.

mkdir700 avatar mkdir700 commented on June 14, 2024

Thank you for your reply, but it doesn't work for me.

There are three pictures about register data at different times.

  1. The first time is the register when the editor is just opened.
image
  1. after the first press of yy.
image
  1. after pressing yy again. "ojroques/nvim-osc52", is the content I copied.
image

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.

from nvim-osc52.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.