vis icon indicating copy to clipboard operation
vis copied to clipboard

[Feature Request]: setting the clipboard as the default register

Open angelacastaneda opened this issue 1 year ago • 7 comments

What feature would you like to see?

what's the best way of making the clipboard the default register in vis? where copying, pasting, and all the rest is no different than clipboard = "unnamedplus" in neovim?

this patch everyone got working for them is very outdated: https://github.com/martanne/vis/issues/1003#issuecomment-1118627247

there was this lua code I found for setting it defacto (I couldn't get it working in my visrc):

vis:map(vis.modes.VISUAL, ' y', '"+y')
vis:map(vis.modes.VISUAL, ' p', '"+p')

but it seems less complete than manually patching in the default register.

someone made a quick patch for me:

diff --git a/vis-registers.c b/vis-registers.c
index 6e21a58..490ee77 100644
--- a/vis-registers.c
+++ b/vis-registers.c
@@ -152,7 +152,9 @@ bool register_slot_put_range(Vis *vis, Register *reg, size_t slot, Text *txt, Fi
 		if (len == SIZE_MAX || !buffer_reserve(buf, len+1))
 			return false;
 		buf->len = text_bytes_get(txt, range->start, len, buf->data);
-		return buffer_append(buf, "\0", 1);
+		if (!buffer_append(buf, "\0", 1))
+			return false;
+		/* fallthrough */
 	}
 	case REGISTER_CLIPBOARD:
 	{

it gets yank working but not paste, and I'm not confident enough in my C to know how sturdy this will actually hold up.

Please share lua and/or C patches below. I am grateful to all that help me detach myself from neovim.

angelacastaneda avatar Oct 29 '24 20:10 angelacastaneda

This works ok for me.

		vis:map(m.NORMAL,      'y', '<vis-register>+<vis-operator-yank>')
		vis:map(m.VISUAL,      'y', '<vis-register>+<vis-operator-yank>')
		vis:map(m.VISUAL_LINE, 'y', '<vis-register>+<vis-operator-yank>')
		vis:map(m.NORMAL,      'd', '<vis-register>+<vis-operator-delete>')
		vis:map(m.VISUAL,      'd', '<vis-register>+<vis-operator-delete>')
		vis:map(m.VISUAL_LINE, 'd', '<vis-register>+<vis-operator-delete>')
		vis:map(m.NORMAL,      'p', '<vis-register>+<vis-put-after>')
		vis:map(m.VISUAL,      'p', '<vis-register>+<vis-put-after>')
		vis:map(m.VISUAL_LINE, 'p', '<vis-register>+<vis-put-after>')
		vis:map(m.NORMAL,      'P', '<vis-register>+<vis-put-before>')
		vis:map(m.VISUAL,      'P', '<vis-register>+<vis-put-before>')
		vis:map(m.VISUAL_LINE, 'P', '<vis-register>+<vis-put-before>')

urosmikanovic avatar Oct 29 '24 21:10 urosmikanovic

@urosmikanovic thanks. seems pretty thorough, but you've got duplicates with VISUAL_LINE delete and NORMAL yank.

angelacastaneda avatar Oct 29 '24 21:10 angelacastaneda

Many times duplicate bug, see e.g. https://github.com/martanne/vis/issues/1003

mcepl avatar Nov 01 '24 10:11 mcepl

I mentioned a patch from that issue above. it is outdated however, so I wanted to open a new issue.

angelacastaneda avatar Nov 01 '24 14:11 angelacastaneda

Is this plugin https://github.com/roguh/vis-copypasta answer to your problems?

mcepl avatar Mar 02 '25 21:03 mcepl

I'll try it out this week. Thanks for remembering this issue!

angelacastaneda avatar Mar 03 '25 04:03 angelacastaneda

ping?

mcepl avatar Mar 24 '25 21:03 mcepl