Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always Overrides unnamed buffer when sync_clipboard is disabled #49

Open
kevintraver opened this issue Nov 19, 2021 · 3 comments
Open
Labels
question Further information is requested

Comments

@kevintraver
Copy link
Contributor

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 "

@aserowy aserowy added bug Something isn't working question Further information is requested and removed bug Something isn't working labels Dec 13, 2021
@aserowy
Copy link
Owner

aserowy commented Dec 13, 2021

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

@kevintraver
Copy link
Contributor Author

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

@aserowy
Copy link
Owner

aserowy commented Dec 17, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants