fix(nvim): ensure Neogit's status is refreshed as necessary

This commit is contained in:
Price Hiller 2024-03-15 23:21:44 -05:00
parent 9015796dd7
commit f4e6abc5fb
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB

View File

@ -36,11 +36,36 @@ return {
end, end,
}) })
local ensure_neogit_refresh = function()
local times_to_repeat = 10
local neogit = require("neogit")
if not neogit then
return
end
neogit.dispatch_refresh()
local repeat_attempt = 0
while repeat_attempt < times_to_repeat do
repeat_attempt = repeat_attempt + 1
vim.wait(100, function()
pcall(neogit.dispatch_refresh)
return true
end)
end
end
vim.api.nvim_create_autocmd("BufEnter", { vim.api.nvim_create_autocmd("BufEnter", {
pattern = "*Neogit*", pattern = "*Neogit*",
callback = function() callback = function()
require("neogit").dispatch_refresh() ensure_neogit_refresh()
end end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "^Neogit*",
callback = function()
ensure_neogit_refresh()
end,
}) })
---@type NeogitConfig ---@type NeogitConfig