[mini.files] Git status and symlinks #2391
Replies: 2 comments 4 replies
|
Thanks for sharing! I've looked quickly through the code. There are some areas that I either don't fully understand or can be improved, like the intention of But the main concern is that this monkey patches |
Sorry to bother you again. If you have some free time, could you please take a quick look at The main reason I'm monkey-patching Click melocal synchronize = MiniFiles.synchronize
MiniFiles.synchronize = function(...)
-- NOTE: Force `is_fresh=false` before `MiniFilesBufferUpdate`
GitStatus.expire()
return synchronize(...)
end
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferUpdate",
callback = function(e)
local buf = e.data.buf_id
local git_root = find_root(buf)
if not git_root then
return
end
local cached, is_fresh = GitStatus.get(git_root)
if cached then
render_git(buf, cached.map)
end
if not is_fresh then
GitStatus.query(git_root, function(state)
render_git(buf, state.map)
end)
end
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesExplorerClose",
callback = function()
GitStatus.expire()
end,
})
Click mevim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferUpdate",
callback = function(e)
local buf = e.data.buf_id
local git_root = find_root(buf)
if not git_root then
return
end
-- NOTE: stale-while-revalidate
local cached = GitStatus.get(git_root)
if cached then
render_git(buf, cached.map)
end
-- WARN: Also runs when a directory is opened for the first time
GitStatus.query(git_root, function(state)
render_git(buf, state.map)
end)
end,
})The only alternative I could come up with is to infer whether the buffer was just created by keeping some buffer-local state, for example, initializing I hope I'm not missing the elephant in the room. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Related
Description
The idea is to add yet another status display for
mini.files.It supports multiple git repositories and lazy fetching. It does not include a git watcher, but it can be refreshed via
MiniFiles.synchronize, which is mapped to=by default.Recipes
Integrate keymaps
Code
Put the code in
<config>/plugin/minifiles_status.lua.Code (version 8)
All reactions