1

Refresh generated nvim config

This commit is contained in:
2024-06-03 21:11:20 +02:00
parent fd506d4921
commit 50723ef645
2114 changed files with 84528 additions and 44473 deletions

View File

@ -12,33 +12,33 @@ function system_clipboard.setup()
system_clipboard.history = require("yanky.history")
if system_clipboard.config.sync_with_ring then
local yanky_clipboard_augroup = vim.api.nvim_create_augroup("YankySyncClipboard", { clear = true })
local fetching = false
vim.api.nvim_create_autocmd("FocusGained", {
group = yanky_clipboard_augroup,
pattern = "*",
callback = function(_)
if fetching then
return
local focused_real = true -- realtime state of focus
local focused_delayed = true -- delayed state of focus
local timer = nil
vim.api.nvim_create_autocmd({ "FocusGained", "FocusLost" }, {
group = vim.api.nvim_create_augroup("YankySyncClipboard", { clear = true }),
callback = function(ev)
if ev.event == "FocusLost" then
focused_real = false
if timer then
timer:stop()
end
timer = vim.defer_fn(function()
if not focused_real then -- still not focused
system_clipboard.on_focus_lost()
focused_delayed = false
end
end, 500)
elseif ev.event == "FocusGained" then
if not focused_delayed then
system_clipboard.on_focus_gained()
end
focused_real = true
focused_delayed = true
end
fetching = true
local ok, err = pcall(system_clipboard.on_focus_gained)
vim.schedule(function()
fetching = false
end)
if not ok then
error(err)
end
end,
})
vim.api.nvim_create_autocmd("FocusLost", {
group = yanky_clipboard_augroup,
pattern = "*",
callback = function(_)
if fetching then
return
end
system_clipboard.on_focus_lost()
-- don't execute focus autocmds while fetching the clipboard,
-- since clipboard tools can steal focus
end,
})
end