[vim/vim] `copy()` in clipboard provider is not called on `yy` even with `clipboard=unnamed,unnamedplus` (Issue #18930)

7 views
Skip to first unread message

Satoru Kitaguchi

unread,
Dec 15, 2025, 6:17:57 AM (yesterday) Dec 15
to vim/vim, Subscribed
satorunooshie created an issue (vim/vim#18930)

Steps to reproduce

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?

Minimal code to reproduct

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

ref: https://github.com/vim/vim/blob/64eeff5784a78e9fa7041df1ccb2fd72516e1858/runtime/doc/eval.txt#L5358-L5383

Actual behavior

"+yy" → copy() is called

yy → copy() is not called (no mess output)

set clipboard? correctly shows clipboard=unnamed,unnamedplus.

Additional notes

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.

Expected behaviour

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.

Version of Vim

64eeff5

Environment

OS: macOS 15.6.1(24G90)
$TERM: xterm-256color
$SHELL: /bin/zsh

Logs and stack traces


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18930@github.com>

Satoru Kitaguchi

unread,
4:45 AM (15 hours ago) 4:45 AM
to vim/vim, Subscribed
satorunooshie left a comment (vim/vim#18930)

Clipboard provider copy() not called for yy with clipboard=unnamedplus

Steps to reproduce

  1. Start Vim with the script below loaded.
  2. Yank a line with "+yy → PB_Copy("+", …) is called (provider works).
  3. Yank a line with plain yy → PB_Copy() is not called.
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

Expected behavior

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.

Actual behavior

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.

My understanding of the spec

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.Message ID: <vim/vim/issues/18930/3659661546@github.com>

Foxe Chen

unread,
2:27 PM (5 hours ago) 2:27 PM
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#18930)

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.Message ID: <vim/vim/issues/18930/3662047882@github.com>

Reply all
Reply to author
Forward
0 new messages