Skip to content

Conversation

@64-bitman
Copy link
Contributor

@64-bitman 64-bitman commented Oct 27, 2025

This is based off of the now defunct clipboard provider feature. I've decided on "&" being the custom register, which can be controlled via the 'regreqfunc' and 'regsetfunc' options. This is based in register.c, instead of clipboard.c, so it shouldn't break any clipboard code.

I didn't use the existing "+" or "*" registers since I think this and those registers should handle different things, instead of trying to fit them together. Also makes things a bit simpler.

I am open to using a different character for the register name.

@64-bitman 64-bitman force-pushed the clipboard_provider_v2 branch 10 times, most recently from a85528a to f462aa6 Compare October 27, 2025 04:28
@64-bitman 64-bitman marked this pull request as draft October 27, 2025 13:40
@64-bitman 64-bitman force-pushed the clipboard_provider_v2 branch from 3e2b9d0 to 91f23e8 Compare October 28, 2025 00:29
@64-bitman 64-bitman marked this pull request as ready for review October 28, 2025 01:23
@64-bitman
Copy link
Contributor Author

I think this is ready

Copy link
Contributor

@dkearns dkearns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I just left a few comments after a quick read through the help.

@64-bitman 64-bitman force-pushed the clipboard_provider_v2 branch 2 times, most recently from ae792b8 to 909b92b Compare October 28, 2025 20:23
@64-bitman
Copy link
Contributor Author

I think this is ready

@64-bitman 64-bitman force-pushed the clipboard_provider_v2 branch 3 times, most recently from 0b94d1e to 8dabf65 Compare October 29, 2025 03:42
@64-bitman
Copy link
Contributor Author

64-bitman commented Oct 29, 2025

Made it so that there are two custom registers ("^" and "&"). Did this since OSC 52 supports multiple selections on X11/Wayland on some terminals, which Neovim provides support for so I think we should do as well.

Comment on lines 7040 to 7057
This options specifies a function to be used whenever the custom
registers |quote_&|, |quote_^| are read. The function takes no
arguments, and should return a |tuple| or |list| containing the
following elements in order:
1. The register name.
2. The register type, conforming to |setreg()|, that the
register will be set to.
3. A |list| containing a list of strings to set the register
to.
Note that this function is not called on |:registers| or |:display|.

The following is a possible example use of this option:
>vim
function GetFunc(reg)
echom "Updating register " .. a:reg
return ('l', readfile('stuff.txt'))
endfunction

set reggetfunc=GetFunc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm lost: how does reggetfunc know which register it's reading if it takes no argument? And yet the examples does… And why does the example only return 3 elements instead of 2? TIL that tuples are available in Vimscript, though.

It might help to see an actual use case for this.

In particular, why is that reading "& will mutate a different register? That seems… icky. I would prefer that reading it simply executes the callback and gives that value to whatever needs the register (a put or expression, presumably).

The docs seem to indicate that reading one of these will mutate another register, but that's not what happens at all. The docs really need to accurately describe the behavior, and a motivating use makes a much better example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm lost: how does reggetfunc know which register it's reading if it takes no argument? And yet the examples does… And why does the example only return 3 elements instead of 2? TIL that tuples are available in Vimscript, though.

I just messed up the documentation, I'll fix this later. Thanks for catching

The docs seem to indicate that reading one of these will mutate another register, but that's not what happens at all. The docs really need to accurately describe the behavior, and a motivating use makes a much better example.

I'm not sure what you mean by "mutate another register". If the "&yy is pressed, then it'll yank to the & register, same for the ^ register. I created this PR for the OSC52 feature, but from what ChatGPT said, there seems to be a bunch of other uses as well. I don't think we need to documentate it though, the user will find their way to this feature likely

Comment on lines 7074 to 7077
nothing and takes two arguments:
1. The register name.
2. The register type being used, conforming to |getregtype()|.
3. A list of strings being written.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar counting comments, of course.

@64-bitman 64-bitman force-pushed the clipboard_provider_v2 branch 2 times, most recently from 31409a8 to 1a434aa Compare October 31, 2025 01:43
@64-bitman 64-bitman force-pushed the clipboard_provider_v2 branch from 1a434aa to 7ccc329 Compare October 31, 2025 01:44
@dkearns
Copy link
Contributor

dkearns commented Oct 31, 2025

I have not yet found the time to have a good look at this PR but I think that some considerable thought should be given to the names used for these registers before they're cast in stone.

global
{not available when compiled without the |+eval|
feature}
This options specifies a function to be used whenever the custom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This options specifies a function to be used whenever the custom
This option specifies a function to be used whenever the custom

Comment on lines +7044 to +7046
2. The register type, conforming to |setreg()|, that the
register will be set to.
3. A |list| containing a list of strings to set the register
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. The register type, conforming to |setreg()|, that the
register will be set to.
3. A |list| containing a list of strings to set the register
1. The register type, conforming to |setreg()|, that the
register will be set to.
2. A |list| containing a list of strings to set the register

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants