refactor(git): adopt lazy-require plugin/git.lua pattern
This commit is contained in:
+17
-26
@@ -57,35 +57,26 @@ local function update_buf(buf, r)
|
||||
vim.b[buf].git_status_string = render(entry)
|
||||
end
|
||||
|
||||
local enabled = false
|
||||
|
||||
function M.enable()
|
||||
if enabled then
|
||||
return
|
||||
end
|
||||
enabled = true
|
||||
repo.on("refresh", function(r)
|
||||
for buf in pairs(r.buffers) do
|
||||
if vim.api.nvim_buf_is_loaded(buf) then
|
||||
update_buf(buf, r)
|
||||
end
|
||||
end
|
||||
vim.cmd.redrawstatus({ bang = true })
|
||||
end)
|
||||
vim.api.nvim_create_autocmd("BufWinEnter", {
|
||||
group = vim.api.nvim_create_augroup(
|
||||
"ow.git.statusline",
|
||||
{ clear = true }
|
||||
),
|
||||
callback = function(args)
|
||||
update_buf(args.buf, nil)
|
||||
end,
|
||||
})
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
repo.on("refresh", function(r)
|
||||
for buf in pairs(r.buffers) do
|
||||
if vim.api.nvim_buf_is_loaded(buf) then
|
||||
update_buf(buf, nil)
|
||||
update_buf(buf, r)
|
||||
end
|
||||
end
|
||||
vim.cmd.redrawstatus({ bang = true })
|
||||
end)
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWinEnter", {
|
||||
group = vim.api.nvim_create_augroup("ow.git.statusline", { clear = true }),
|
||||
callback = function(args)
|
||||
update_buf(args.buf, nil)
|
||||
end,
|
||||
})
|
||||
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_is_loaded(buf) then
|
||||
update_buf(buf, nil)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user