Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvim system clipboard synchronization is gone after installing nvim using bob #5

Open
SteveLauC opened this issue Jan 2, 2023 · 0 comments

Comments

@SteveLauC
Copy link
Owner

Neovim has its own clipboard buffer, but I don't like it, so when using it, I always make it sync with my system clipboard through the following configuration:

vim.opt.clipboard:append("unnamedplus")

This morning, I needed to test an issue with multiple versions of Neovim, so I decided to give bob a try. Honestly, this package manager is pretty good, download and switches are done within a few seconds, blazingly fast!

However, when using the nvim installed through bob, I found my system clipboard integration was no longer working. Alright, then let's try to figure out what's wrong here, Read The Fxxking Manual, executing :help clipboard inside nvim tells us that:

Nvim has no direct connection to the system clipboard. Instead it depends on
a |provider| which transparently uses shell commands to communicate with the
system clipboard or any other clipboard "backend".

To ALWAYS use the clipboard for ALL operations (instead of interacting with
the "+" and/or "*" registers explicitly): >vim
    set clipboard+=unnamedplus

See 'clipboard' for details and options.

							      *clipboard-tool*
The presence of a working clipboard tool implicitly enables the '+' and '*'
registers. Nvim looks for these clipboard tools, in order of priority:

  - |g:clipboard|
  - pbcopy, pbpaste (macOS)
  - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set)
  - waycopy, waypaste (if $WAYLAND_DISPLAY is set)
  - xclip (if $DISPLAY is set)
  - xsel (if $DISPLAY is set)
  - lemonade (for SSH) https://github.com/pocke/lemonade
  - doitclient (for SSH) https://www.chiark.greenend.org.uk/~sgtatham/doit/
  - win32yank (Windows)
  - termux (via termux-clipboard-set, termux-clipboard-set)
  - tmux (if $TMUX is set)

From the documentation, we can know that nvim itself has no capacity to communicate with the system clipboard, it needs some external command line tools to help it handle that, and this documentation lists all the available tools in order of priority.

With this, I kinda think that maybe such a tool is missing on my machine, and my guess is right. :checkhealth explicitly tells us that:

provider: health#provider#check

Clipboard (optional) ~
- WARNING No clipboard tool found. Clipboard registers (`"+` and `"*`) will not work.
  - ADVICE:
    - :help |clipboard|

This is weird, I don't recall that I have installed one of the above tools and all I did in the past is simply executing

sudo dnf install neovim

to install nvim itself.

Is it possible that dnf will help me install one of the above tools at the same time as installing nvim, to verify this:

$ sudo dnf install neovim                         
[sudo] password for steve: 
Last metadata expiration check: 2:30:56 ago on Mon 02 Jan 2023 01:55:22 PM CST.
Dependencies resolved.
================================================================================
 Package              Arch        Version                    Repository    Size
================================================================================
Installing:
 neovim               x86_64      0.8.1-1.fc36               updates      5.8 M
Installing dependencies:
 compat-lua-libs      x86_64      5.1.5-20.fc36              fedora       167 k
 libtermkey           x86_64      0.22-2.fc36                fedora        29 k
 libtree-sitter       x86_64      0.20.7-1.fc36              updates       97 k
 libvterm             x86_64      0.3-1.fc36                 updates       43 k
 luajit               x86_64      2.1.0-0.25beta3.fc36       updates      402 k
 luajit2.1-luv        x86_64      1.44.2.1-1.fc36            updates       72 k
 msgpack              x86_64      3.1.0-9.fc36               fedora        30 k
 unibilium            x86_64      2.1.1-2.fc36               fedora        36 k
Installing weak dependencies:
 xsel                 x86_64      1.2.0-30.fc36              fedora        28 k

Transaction Summary
================================================================================
Install  10 Packages

Total download size: 6.7 M
Installed size: 26 M
Is this ok [y/N]: 

Everything is clear by now! dnf will install xsel when installing neovim, when switched to bob, I removed nvim (installed
through dnf ) as well as xsel from my machine, which means there is NO clipboard tool available to nvim to use...

Now that we know the root of the problem, the solution is pretty simple, just install one clipboard tool that is listed in the documentation, I choose wl-clipboard as I am using wayland. xsel, as tested by Fedora package maintainers, will definitely work, so you can also install that:

$ sudo dnf install -y wl-clipboard

# To install `xsel`
$ sudo dnf install -y xsel

Let's run :checkhealth again to give it a double check:

provider: health#provider#check

Clipboard (optional) ~
- OK Clipboard tool found: wl-copy

Yep, system clipboard integration is back:)

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

No branches or pull requests

1 participant