mirror of
https://github.com/hydroxycarbamide/dotfiles.git
synced 2025-05-07 13:29:08 -04:00
Update yazi and its plugins
This commit is contained in:
parent
ab39adc2f3
commit
09065ab756
16 changed files with 1805 additions and 113 deletions
33
dot_config/yazi/plugins/vcs-files.yazi/readonly_main.lua
Normal file
33
dot_config/yazi/plugins/vcs-files.yazi/readonly_main.lua
Normal file
|
@ -0,0 +1,33 @@
|
|||
--- @since 25.4.8
|
||||
|
||||
local root = ya.sync(function() return cx.active.current.cwd end)
|
||||
|
||||
local function fail(content) return ya.notify { title = "VCS Files", content = content, timeout = 5, level = "error" } end
|
||||
|
||||
local function entry()
|
||||
local root = root()
|
||||
local output, err = Command("git"):cwd(tostring(root)):args({ "diff", "--name-only", "HEAD" }):output()
|
||||
if err then
|
||||
return fail("Failed to run `git diff`, error: " .. err)
|
||||
elseif not output.status.success then
|
||||
return fail("Failed to run `git diff`, stderr: " .. output.stderr)
|
||||
end
|
||||
|
||||
local id = ya.id("ft")
|
||||
local cwd = root:into_search("Git changes")
|
||||
ya.mgr_emit("cd", { Url(cwd) })
|
||||
ya.mgr_emit("update_files", { op = fs.op("part", { id = id, url = Url(cwd), files = {} }) })
|
||||
|
||||
local files = {}
|
||||
for line in output.stdout:gmatch("[^\r\n]+") do
|
||||
local url = cwd:join(line)
|
||||
local cha = fs.cha(url, true)
|
||||
if cha then
|
||||
files[#files + 1] = File { url = url, cha = cha }
|
||||
end
|
||||
end
|
||||
ya.mgr_emit("update_files", { op = fs.op("part", { id = id, url = Url(cwd), files = files }) })
|
||||
ya.mgr_emit("update_files", { op = fs.op("done", { id = id, url = cwd, cha = Cha { kind = 16 } }) })
|
||||
end
|
||||
|
||||
return { entry = entry }
|
Loading…
Add table
Add a link
Reference in a new issue