feat: support customizing git status sign and style, closes #21
This commit is contained in:
@@ -34,3 +34,42 @@ id = "git"
|
||||
name = "*/"
|
||||
run = "git"
|
||||
```
|
||||
|
||||
## Advanced
|
||||
|
||||
> [!NOTE]
|
||||
> This section currently requires Yazi nightly that includes https://github.com/sxyazi/yazi/pull/1637
|
||||
|
||||
You can customize the [Style](https://yazi-rs.github.io/docs/plugins/layout#style) of the status sign with:
|
||||
|
||||
- `THEME.git_modified`
|
||||
- `THEME.git_added`
|
||||
- `THEME.git_untracked`
|
||||
- `THEME.git_ignored`
|
||||
- `THEME.git_deleted`
|
||||
- `THEME.git_updated`
|
||||
|
||||
For example:
|
||||
|
||||
```lua
|
||||
-- ~/.config/yazi/init.lua
|
||||
THEME.git_modified = ui.Style():fg("blue")
|
||||
THEME.git_deleted = ui.Style():fg("red"):bold()
|
||||
```
|
||||
|
||||
You can also customize the text of the status sign with:
|
||||
|
||||
- `THEME.git_modified_sign`
|
||||
- `THEME.git_added_sign`
|
||||
- `THEME.git_untracked_sign`
|
||||
- `THEME.git_ignored_sign`
|
||||
- `THEME.git_deleted_sign`
|
||||
- `THEME.git_updated_sign`
|
||||
|
||||
For example:
|
||||
|
||||
```lua
|
||||
-- ~/.config/yazi/init.lua
|
||||
THEME.git_modified_sign = "M"
|
||||
THEME.git_deleted_sign = "D"
|
||||
```
|
||||
|
||||
@@ -117,13 +117,13 @@ local function setup(st, opts)
|
||||
[1] = THEME.git_updated and ui.Style(THEME.git_updated) or ui.Style():fg("#1e90ff"),
|
||||
}
|
||||
-- TODO: Use nerd-font icons as default matching Yazi's default behavior
|
||||
local icons = {
|
||||
[6] = THEME.git_modified and THEME.git_modified.icon or "*",
|
||||
[5] = THEME.git_added and THEME.git_added.icon or "+",
|
||||
[4] = THEME.git_untracked and THEME.git_untracked.icon or "?",
|
||||
[3] = THEME.git_ignored and THEME.git_ignored.icon or "!",
|
||||
[2] = THEME.git_deleted and THEME.git_deleted.icon or "-",
|
||||
[1] = THEME.git_updated and THEME.git_updated.icon or "U",
|
||||
local signs = {
|
||||
[6] = THEME.git_modified_sign and THEME.git_modified_sign or "*",
|
||||
[5] = THEME.git_added_sign and THEME.git_added_sign or "+",
|
||||
[4] = THEME.git_untracked_sign and THEME.git_untracked_sign or "?",
|
||||
[3] = THEME.git_ignored_sign and THEME.git_ignored_sign or "!",
|
||||
[2] = THEME.git_deleted_sign and THEME.git_deleted_sign or "-",
|
||||
[1] = THEME.git_updated_sign and THEME.git_updated_sign or "U",
|
||||
}
|
||||
|
||||
Linemode:children_add(function(self)
|
||||
@@ -134,12 +134,12 @@ local function setup(st, opts)
|
||||
change = dir == "" and 3 or st.repos[dir][tostring(url):sub(#dir + 2)]
|
||||
end
|
||||
|
||||
if not change or icons[change] == "" then
|
||||
if not change or signs[change] == "" then
|
||||
return ui.Line("")
|
||||
elseif self._file:is_hovered() then
|
||||
return ui.Line { ui.Span(" "), ui.Span(icons[change]) }
|
||||
return ui.Line { ui.Span(" "), ui.Span(signs[change]) }
|
||||
else
|
||||
return ui.Line { ui.Span(" "), ui.Span(icons[change]):style(styles[change]) }
|
||||
return ui.Line { ui.Span(" "), ui.Span(signs[change]):style(styles[change]) }
|
||||
end
|
||||
end, opts.order)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user