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

Deferred Clipboard only kicks in after focus is lost at least once #2

Open
Taaqif opened this issue Jan 4, 2023 · 5 comments
Open

Comments

@Taaqif
Copy link

Taaqif commented Jan 4, 2023

Due to syncing Windows and WSL via win32yank.exe, there is a notable lag when copying thing to the clipboard and on WSL, I see a massive improvement in performance when using this plugin! Thank you.

The issue I have is when I open Neovim for the first time, I don't see this performance boost until I at least lose focus once.
I believe its due to the fact that schedule_disable_of_continuous_clipboard_sync_on_focus_change only triggers the vim.o.clipboard = nil after either FocusGained or FocusLost

Is it possible to call this earlier in the setup to make the performance boost immediately available rather than having to trigger a FocusLost manually each time

@EtiamNullam
Copy link
Owner

EtiamNullam commented Jan 4, 2023

I'm glad it's useful for you!

So do you still want to use the fallback in case of clients that do not have support for change events? I believe it's not possible until support for focus change events is truly detected - as any of them fire the first time.

If you don't care for fallback just leave clipboard at nil (or "", empty string, default value) as in basic usage example. Though you might want to use the lazy version to also delay the first clipboard access, increasing the startup time.

@Taaqif
Copy link
Author

Taaqif commented Jan 5, 2023

Would it be possible to check the availability of the Focus changed events using something like

local hasFocusEvent = vim.api.nvim_command_output(([[echo exists('##FocusLost')]])
if hasFocusEvent == '1' then
  vim.o.clipboard = nil
end

This should cater for the fallback as the exists command returns only if the client supports the provided command

@EtiamNullam
Copy link
Owner

EtiamNullam commented Jan 5, 2023

It seems to always return 1 for me, even for terminals which don't support it. Does it work for you as expected?

EDIT: Submitted additional issue here: neovim/neovim#21655

@EtiamNullam
Copy link
Owner

exists cannot be used to determine support of terminal capabilities. Check the linked issue above for more details.

Let's keep the issue open as the issue still stands. Maybe there is still a better solution for it.

@Taaqif
Copy link
Author

Taaqif commented Jan 6, 2023

Ah thats an oversight on my part, the exists command returns true if neovim supports it but that's not to say the terminal does.
Thanks for helping me understand that.

Hopefully there is a smarter way to defer the clipboard on startup as its definitely something I find useful.
Nonetheless, I will just set my clipboard to nil as i'm using a terminal that does support this.

Thanks again!

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

No branches or pull requests

2 participants