I start my coding workspaces in tmux sessions which persist when I log out. If I switch from a wayland session to an x11 session, then my copy and paste functionality in those neovim sessions are broken because it’s still trying to use wl-copy. To be more precise:

  1. Start a wayland session.
  2. Open a terminal and start a tmux session.
  3. Open neovim and do some work.
  4. Log out of wayland, log into an X11 environment
  5. Open a terminal and reconnect to the tmux session
  6. "+y broken. clipboard: error invoking wl-copy: Failed to connect to a Wayland server...

Restarting neovim isn’t sufficient. I have to restart the entire tmux session or switch back to wayland. Is there some short cut I can take here?

  • sudoOP
    link
    fedilink
    arrow-up
    4
    ·
    2 months ago

    Manipulating vim.g.clipboard is the trick. I’ll have to write some command that sets the clipboard provider directly.

  • gudu
    link
    fedilink
    arrow-up
    3
    ·
    2 months ago

    Heho,

    Just a guess. The tmux session may persist env. Thus nvim reads eg DISPLAY and thinks it must still be a wayland compositor.

    Hope it helps

    • bjornsno@lemm.ee
      link
      fedilink
      arrow-up
      5
      ·
      2 months ago

      This is exactly what happens. Actually the whole Wayland/xorg thing is not necessary, simply exiting a Wayland session and starting a new one will probably have the same effect, might depend on compositor. But it doesn’t help knowing that it’s the cause, I’ve known it for years, no closer to a solution. Obviously closing the tmux session and starting over is a “fix” in the same way that turning the machine off and on again is a fix. Kinda defeats the purpose of persistent tmux sessions.

    • sudoOP
      link
      fedilink
      arrow-up
      2
      ·
      2 months ago

      Thats for sure what’s happening. The remaining error message makes that clear but I couldn’t copy the full message