5

I want to let CopyQ clipboard manager handle clipboard (I am using set clipboard+=unnamed setting). To that end, this setting was added to init.vim file:

    let g:clipboard = {  
        \ 'name': 'myClipboard',  
        \ 'copy': {  
        \    '+': 'copyq add -',  
        \    '*': 'copyq add -',  
        \ },
        \ 'paste': {
        \    '+': '+',
        \    '*': '*',
        \ },
        \ 'cache_enabled': 1,
        \ }

It sort of works, but there are couple of problems/questions:

  1. Every time nvim is started, a clipboard: error: -1 error is briefly shown on the status line. What's that about?
  2. copyq add - does add the item to copyq clipboard, but it doesn't select it, i.e. Ctrl+v would not paste the item. To also select it, copyq select 0 command should be ran; can this be combined in clipboard.copy.{+,*}?
  3. How to set clipboard.paste.{+,*} to use copyq?

Related:

Edit: additional info:

NVIM v0.4.4
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-eK2ojg/neovim-0.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=1 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim-eK2ojg/neovim-0.4.4/build/config -I/build/neovim-eK2ojg/neovim-0.4.4/src -I/usr/include -I/usr/include/lua5.1 -I/build/neovim-eK2ojg/neovim-0.4.4/build/src/nvim/auto -I/build/neovim-eK2ojg/neovim-0.4.4/build/include
Compiled by [email protected]

Features: +acl +iconv +tui

:help clipboard suggests g:clipboard value is to be a string, not an array:

:help clipboard
                                 *g:clipboard*
To configure a custom clipboard tool, set g:clipboard to a dictionary.
For example this configuration integrates the tmux clipboard: >

    let g:clipboard = {
          \   'name': 'myClipboard',
          \   'copy': {
          \      '+': 'tmux load-buffer -',
          \      '*': 'tmux load-buffer -',
          \    },
          \   'paste': {
          \      '+': 'tmux save-buffer -',
          \      '*': 'tmux save-buffer -',
          \   },
          \   'cache_enabled': 1,
          \ }
4
  • g:clipboard expects an array, not a string - see the help for the variable. It's hard to tell without the :messages, though Jul 10, 2021 at 10:33
  • @Zoe nvim help suggests it should be str, not array. See edits. :messages only displays the same clipboard error as described in 1.
    – laur
    Jul 10, 2021 at 10:46
  • ah, I see. 0.6.0-dev says it should be an array - assumed that applied to earlier versions as well. Jul 10, 2021 at 10:51
  • Welcome to Vi and Vim!
    – D. Ben Knoble
    Jul 10, 2021 at 20:01

1 Answer 1

1

A possible solution is to send the clipboard to xclip and allow copyq to pick up from there:

let g:clipboard = {
  \   'name': 'xclip-xfce4-clipman',
  \   'copy': {
  \      '+': 'xclip -selection clipboard',
  \      '*': 'xclip -selection clipboard',
  \    },
  \   'paste': {
  \      '+': 'xclip -selection clipboard -o',
  \      '*': 'xclip -selection clipboard -o',
  \   },
  \   'cache_enabled': 1,
  \ }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.