zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
22.03k stars 673 forks source link

Zellij Clipboard Functionality: Limitations for Integrating Neovim Registers #2637

Open d0u9 opened 1 year ago

d0u9 commented 1 year ago

I am a user of Neovim and heavily use its registers. It is convenient to press y to copy some text from Neovim running on the remote host in Zellij to my local laptop's system clipboard.

When I used tmux, it had integrated tmux set-buffer and tmux save-buffer functions that allowed me to pipe their contents into tmux's clipboard. Then, tmux copies these contents to my local clipboard using osc52. Neovim integrated with tmux's clipboard by default, and you can find more information about it by running :help clipboard in nvim.

However, after switching to Zellij, the advanced terminal multiplexer, I discovered that it doesn't have tools like zellij action copy and zellij action paste, which means that Neovim cannot dump its registers' content to the clipboard.

I am wondering if this is a limitation of Zellij's clipboard functionality or if I have some misunderstanding about how it works.

imsnif commented 1 year ago

Hey - so, Zellij intentionally does not manage a clipboard. We might add this functionality to plugins in the future.

But I'm wondering - seems to me like the multiplexer in this case is a bit of an extraneous hop, no? Why not have nvim send the OSC52 signal directly? Zellij will pick this up, send it to your terminal and it'll get to your clipboard. No need to go the extra step... or am I missing something?

d0u9 commented 1 year ago

It seems that due to nvim's design philosophy, here is an excerpt from nvim's help:

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".

imsnif commented 1 year ago

I get the nvim philosophy - ours is similar :)

How about using something like https://github.com/ojroques/nvim-osc52 then?

d0u9 commented 1 year ago

Sounds interesting. will try it. Thank you.

hardfau1t commented 1 year ago

there is also osc52 tool which can be used to copy from remote, but it works only outside of zellij, Not sure whats going on here(Honestly i just heard about osc52😛)

EDIT: my bad, it doesn't work with tmux, screen

hardfau1t commented 1 year ago

I get the nvim philosophy - ours is similar :)

How about using something like https://github.com/ojroques/nvim-osc52 then?

this works, just make sure to comment out copy_command and copy_clipboard in remote zellij config

andrius commented 8 months ago

Neovim v10 release is soon and it have a build-in OSC52 integration currently. However it does not work with zellij (tmux user here). Nvim's :checkhealth command does not find a clipboard provider.

I use mosh/ssh and literally live in the remote session, have nothing installed on my laptop

justinvson-pd commented 7 months ago

I'm having the same issue, and when I manually add osc-52 as clipboard provider, it will copy just fine but when pasting it will time out, with "Waiting for OSC 52 response from the terminal. Press Ctrl-C to interrupt...". Using kitty to ssh to remote server where I have nvim locally installed, zellij as well

andrius commented 7 months ago

I'm having the same issue, and when I manually add osc-52 as clipboard provider, it will copy just fine but when pasting it will time out, with "Waiting for OSC 52 response from the terminal. Press Ctrl-C to interrupt...". Using kitty to ssh to remote server where I have nvim locally installed, zellij as well

@justinvson-pd if you have resolved the issue (I use both foot and Kitty), could you share your config?

justinvson-pd commented 7 months ago

I'm having the same issue, and when I manually add osc-52 as clipboard provider, it will copy just fine but when pasting it will time out, with "Waiting for OSC 52 response from the terminal. Press Ctrl-C to interrupt...". Using kitty to ssh to remote server where I have nvim locally installed, zellij as well

@justinvson-pd if you have resolved the issue (I use both foot and Kitty), could you share your config?

I am currently using "just use CTRL-SHIFT-V as paste" as a workaround. Paste from nvim buffer still times out.

whmountains commented 5 months ago

I think there are two problems here:

  1. Neovim does not detect OSC52 support when inside Zellij (not sure why)
  2. It is not possible to paste using OSC52 while inside Zellij. (reported using foot, kitty and iTerm2 emulators)

For the first problem, it's unclear whether Neovim or Zellij is at fault. At any rate there is a pretty easy workaround to force Neovim to use OSC52. That workaround is documented under :h clipboard-osc52.

The second problem is almost certainly an issue with Zellij since it has been documented with multiple terminal emulators. I can even reproduce it without Neovim at all, using theimpostor/osc or rumpelsepp/oscclip.

It appears that while Zellij added support for passing through OSC52 copy events in #1644, support for paste events was never added. In fact, @theimpostor already opened #2647 about this.