Fixing Generation of wl-clipboard Transient Windows When Used with Neovim
I have been plagued recently with issues stemming from neovim's interaction with the system clipboard. Every time I would copy text in nvim, I'd get a transient wl-clipboard window. Inside nvim, paste would work fine, but outside it, the system clipboard seemed not to get the contents.
I finally tracked it down to how Wezterm is interacting with Wayland.
And the culprit appears to be... the muxer.
Let me explain.
Wezterm does not enable a muxer
I had the following in my configuration:
config.unix_domains = {
{
name = 'unix',
},
}
and I had setup my dropdown terminal command to wezterm start --domain unix --attach
(with a few other arguments).
This starts a multiplexer on a unix socket.
On the first invocation of the dropdown, things work fine. However, on subsequent invocations, I would run into issues, and I realized that this is because the panes are now running in the unix socket, which lives outside my Wayland session. I'd also configured Wezterm to connect to the muxer anytime I started splitting panes, which meant that even other windows I spawned were exhibiting the issue.
Removing this configuration, and removing the auto-attachment to the unix domain for my dropdown, fixed the issue.
The downside: if I close all windows, I no longer have the history running in the background. However, I have also started using resurrect.wezterm, so I essentially get everything I need with regards to saved sessions anyways.
The second approach, which also didn't work
On 2024-10-07, I had tracked it down to the following setting in my Wezterm config:
config.enable_wayland = true
I'd only recently enabled this, and realized that it's entirely possible this was the problem. So I toggled the flag... and now everything is working correctly.
I'm not happy that it has to run under XWayland, but if it works, I'm not going to argue.
Original post
For some reason, with a recent update to the wl-clipboard package or Neovim or both, I started seeing transient wl-clipboard windows, with a corresponding system notification, every time I'd do something that would write to a copy register in Neovim.
It was really annoying.
The fix turned out to be pretty easy in the end. Previously, I'd used this:
set clipboard+=unnamedplus
Switching it over to the following fixed the issue entirely:
set clipboard=unnamed,unnamedplus