codesnap.nvim icon indicating copy to clipboard operation
codesnap.nvim copied to clipboard

Can't save to clipboard on macOS

Open jondkinney opened this issue 1 year ago • 4 comments

I can successfully save to disk, but I can't save to the clipboard. I even complied it fully (as a troubleshooting step) versus the default (which also didn't work) and it still yields this error crashing neovim.

Error: Process exited with error code 138

macOS 14.5 (23F79)

neovim version

NVIM VO. 10.0
Build type: Release
LuaJIT 2.1.1713484068

Using kitty 0.36.0

jondkinney avatar Aug 28 '24 23:08 jondkinney

Hi @jondkinney, can you provide screen record for describe this issue? Cause I'm on MacOS but Apple Silicon, I can't reproduce this issue

mistricky avatar Sep 22 '24 04:09 mistricky

I've just installed CodeSnap and can't save to clipboard either. Running on a M4 MacMini.

return {
	"mistricky/codesnap.nvim",
	build = "make",
	keys = {
		{ "<leader>cc", "<cmd>CodeSnap<cr>", mode = "x", desc = "Save selected code snapshot into clipboard" },
		{ "<leader>cs", "<cmd>CodeSnapSave<cr>", mode = "x", desc = "Save selected code snapshot in ~/Pictures" },
	},
	config = function()
		require("codesnap").setup({
			mac_window_bar = true,
			title = "",
			has_breadcrumbs = true,
			watermark = "",
			save_path = "~/Pictures",
			bg_theme = "bamboo",
		})
	end,
}

EDIT It does work but I have to execute the command twice for it to be put into clipboard.

Kazuto avatar Feb 28 '25 09:02 Kazuto

Hey @Kazuto there's a fix for this; it has to do with how the v and x registers are updated (after exiting them). What I've done to get this to work:

  -- other configs...
  keys = {
    { "<leader>cs", "<Esc><cmd>CodeSnap<cr>", mode = "x", desc = "Save selected code snapshot into clipboard" },
    { "<leader>cS", "<Esc><cmd>CodeSnapSave<cr>", mode = "x", desc = "Save selected code snapshot in ~/Pictures" },
  },
 -- ...

And it works without having to do the command twice!

felixnorden avatar Mar 18 '25 22:03 felixnorden

Interestingly, saving to clipboard works for me on OSX out of the box - no additional config, running on M4 Max + Kitty

sarahsturgeon avatar May 06 '25 17:05 sarahsturgeon