tmux.nvim icon indicating copy to clipboard operation
tmux.nvim copied to clipboard

Always Overrides unnamed buffer when sync_clipboard is disabled

Open kevintraver opened this issue 3 years ago • 3 comments

When sync_clipboard is disabled, there is no way to set the unnamed register

Example:

lua vim.fn.setreg('"', 'some text to copy')

Then trying to paste:

p will return whatever is in the tmux buffer instead of register "

kevintraver avatar Nov 19 '21 20:11 kevintraver

hmm,

the documentation states that the option is overwriting regs * and +.

    -- sync clipboard overwrites vim.g.clipboard to handle * and +
    -- registers. If you sync your system clipboard without tmux, disable
    -- this option!
    sync_clipboard = true,

The " reg is a little bit special, because it gets overwritten with everything (even using setreg). Thus, syncing from tmux is overwriting " every time. We can only handle this case, if we read the " beforehand and set it back after the sync has taken place. The question is if it is applicable cause doing so would prevent dd in one nvim and p" in the second.

Kind regards Alexander

PS: I leave the report open. You can close it or we use it to track a pr (if you need that option configurable).

aserowy avatar Dec 13 '21 07:12 aserowy

Heres an example of where this in issue:

https://github.com/kyazdani42/nvim-tree.lua/blob/2e33b1654384921ec1cc9656a2018744f3f1ce81/lua/nvim-tree/fs.lua#L350

Notice nvim-tree copies to the " clipboard, but as soon tmux.nvim changes the window the copy_sync will override the " register

kevintraver avatar Dec 17 '21 04:12 kevintraver

hmm, is this really the vim way for handling copies? (plz dont get me wrong, im unsure what the vim way is in this situation)

We could get this fixed by syncing " in advance if the latest tmux buffer != " or ignore the " which would destroy dd -> change nvim instance -> p.

aserowy avatar Dec 17 '21 06:12 aserowy