feat: allow custom icons for git states
This commit is contained in:
@@ -15,8 +15,7 @@ ya pack -a yazi-rs/plugins:git
|
|||||||
Add the following to your `~/.config/yazi/init.lua`:
|
Add the following to your `~/.config/yazi/init.lua`:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require("git"):setup {
|
require("git"):setup()
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
And register it as fetchers in your `~/.config/yazi/yazi.toml`:
|
And register it as fetchers in your `~/.config/yazi/yazi.toml`:
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ local save = ya.sync(function(st, states)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local function setup(st, opts)
|
local function setup(st, opts)
|
||||||
opts = opts or {}
|
|
||||||
opts.order = opts.order or 1500
|
|
||||||
|
|
||||||
st.states = {}
|
st.states = {}
|
||||||
|
opts = opts or {}
|
||||||
|
opts.order = opts.order or 500
|
||||||
|
|
||||||
local styles = {
|
local styles = {
|
||||||
["M"] = THEME.git_modified and ui.Style(THEME.git_modified) or ui.Style():fg("blue"),
|
["M"] = THEME.git_modified and ui.Style(THEME.git_modified) or ui.Style():fg("blue"),
|
||||||
["A"] = THEME.git_added and ui.Style(THEME.git_added) or ui.Style():fg("green"),
|
["A"] = THEME.git_added and ui.Style(THEME.git_added) or ui.Style():fg("green"),
|
||||||
@@ -58,11 +58,18 @@ local function setup(st, opts)
|
|||||||
["D"] = THEME.git_deleted and ui.Style(THEME.git_deleted) or ui.Style():fg("red"),
|
["D"] = THEME.git_deleted and ui.Style(THEME.git_deleted) or ui.Style():fg("red"),
|
||||||
["U"] = THEME.git_updated and ui.Style(THEME.git_updated) or ui.Style():fg("blue"),
|
["U"] = THEME.git_updated and ui.Style(THEME.git_updated) or ui.Style():fg("blue"),
|
||||||
}
|
}
|
||||||
|
local icons = {
|
||||||
|
["M"] = THEME.git_modified and THEME.git_modified.icon or "M",
|
||||||
|
["A"] = THEME.git_added and THEME.git_added.icon or "A",
|
||||||
|
["?"] = THEME.git_untracked and THEME.git_untracked.icon or "?",
|
||||||
|
["D"] = THEME.git_deleted and THEME.git_deleted.icon or "D",
|
||||||
|
["U"] = THEME.git_updated and THEME.git_updated.icon or "U",
|
||||||
|
}
|
||||||
|
|
||||||
Linemode:children_add(function(self)
|
Linemode:children_add(function(self)
|
||||||
local state = st.states[tostring(self._file.url)]
|
local s = st.states[tostring(self._file.url)]
|
||||||
if state then
|
if s and icons[s] ~= "" then
|
||||||
return ui.Line { ui.Span(" "), ui.Span(state):style(styles[state]) }
|
return ui.Line { ui.Span(" "), ui.Span(icons[s]):style(styles[s]) }
|
||||||
else
|
else
|
||||||
return ui.Line {}
|
return ui.Line {}
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user