--- 
canonical: 'https://mwop.net/blog/2024-09-23-nvim-wl-clipboard.html'
title: 'Fixing Generation of wl-clipboard Transient Windows When Used with Neovim'
author: "[Matthew Weier O'Phinney](https://mwop.net)"
created: '2024-09-23T12:34:15-05:00'
updated: '2024-10-08T13:42:15-05:00'
tags:
  - gnome-shell
  - neovim
  - nvim
  - til
  - wezterm
  - wl-clipboard

---
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:

```lua
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:

```lua
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](https://github.com/bugaevc/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:

```vim
set clipboard+=unnamedplus
```

Switching it over to the following fixed the issue entirely:

```vim
set clipboard=unnamed,unnamedplus
```