I’m using a custom clipboard provider via v:clipproviders and clipmethod.
The provider works correctly when I explicitly yank to + or * (e.g. "+yy" or "*yy").
However, even when clipboard=unnamed,unnamedplus is set, calling plain yy does not trigger the provider’s copy() callback.
According to :help v:clipproviders, clipboard providers override the + and * registers (and integration is done via clipmethod, not via the clipboard option).
Still, with unnamedplus, an unspecified yank should be redirected to the + register, meaning yy should go through the provider as well.
I would expect copy("+", …) to be called on yy, but it isn’t.
Is this intentional, or is it a bug?
vim -Nu .minimal.vimrc
func Available() return v:true endfunc func Copy(reg, type, str) echom "Register: " .. a:reg echom "Register type: " .. a:type echom "Contents: " .. string(a:str) endfunc func Paste(reg) return ("b40", ["this", "is", "the", a:reg, "register!"]) endfunc let v:clipproviders["test"] = { \ "available": function("Available"), \ "copy": { \ "+": function("Copy"), \ "*": function("Copy") \ }, \ "paste": { \ "+": function("Paste"), \ "*": function("Paste") \ }, \ } set clipmethod^=test set clipboard=unnamed,unnamedplus
"+yy" → copy() is called
yy → copy() is not called (no mess output)
set clipboard? correctly shows clipboard=unnamed,unnamedplus.
The clipboard provider itself works normally when accessing + or * explicitly.
It seems the redirection by 'clipboard' (unnamed / unnamedplus) does not interact with the provider as expected.
If this behavior is intended, the documentation may need clarification.
With clipboard=unnamedplus, an unspecified yank (yy) should be redirected to the + register.
Since + is overridden by the clipboard provider, the provider’s copy("+", …) should be called, producing the echom output.
OS: macOS 15.6.1(24G90)
$TERM: xterm-256color
$SHELL: /bin/zsh
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
vim9script if !has('clipboard_provider') | finish | endif if !executable('pbcopy') || !executable('pbpaste') | finish | endif var last_regtype: dict<string> = { '*': 'v', '+': 'v' } def PB_Available(): bool return v:true enddef def PB_Copy(reg: string, regtype: string, lines: list<string>) last_regtype[reg] = regtype var payload = join(lines, "\n") .. (regtype ==# 'V' ? "\n" : '') call system('pbcopy', payload) " For debugging, you can also: " echom printf('PB_Copy(%s, %s, %s)', reg, regtype, string(lines)) enddef def PB_Paste(reg: string): list<any> var lines = systemlist('pbpaste') var rt = get(last_regtype, reg, 'v') if v:shell_error | return [rt, []] | endif def NormalizeCRLF(l: list<string>): list<string> return mapnew(l, (_, v) => substitute(v, '\r\(\n\)\@=', '', 'g')) enddef lines = NormalizeCRLF(lines) return [rt, lines] enddef v:clipproviders.pb = { available: PB_Available, paste: { '+': PB_Paste, '*': PB_Paste }, copy: { '+': PB_Copy, '*': PB_Copy }, } set clipmethod=pb set clipboard=unnamed,unnamedplus
With set clipboard=unnamed,unnamedplus, an unspecified yank (yy) should also be written to the + register. Since the + register is overridden by the clipboard provider, I expect:
yy to go through the provider, and
PB_Copy("+", …) to be called.
PB_Copy("+", …) is only called for explicit "+ or "* operations.
A plain yy does not call the provider’s copy() callback, even though clipboard=unnamed,unnamedplus is set.
Based on :help v:clipproviders, my understanding is:
paste() should return [regtype, lines].
copy() receives the register name, register type, and list of text lines.
Undefined callbacks should simply not be called.
Keeping some register-type state (e.g. storing the last used regtype per register) is acceptable.
If any of this understanding is incorrect, I’d appreciate clarification.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
This is technically intended behaviour. However, I think it may make more sense for users for the clipboard provider feature to respect some clipboard option values. I will create a PR for this.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()