feat: allow changing the colors of the tags
This commit is contained in:
@@ -4,6 +4,8 @@ Bring macOS's awesome tagging feature to Yazi! The plugin it's only available fo
|
||||
|
||||
Authors: [@AnirudhG07](https://github.com/AnirudhG07), and [@sxyazi](https://github.com/sxyazi)
|
||||
|
||||
Note that this plugin is still under development.
|
||||
|
||||
## Installation
|
||||
|
||||
Install the plugin itself, and [jdberry/tag](https://github.com/jdberry/tag) used to tag files:
|
||||
@@ -18,7 +20,18 @@ brew update && brew install tag
|
||||
Add the following to your `~/.config/yazi/init.lua`:
|
||||
|
||||
```lua
|
||||
require("mactag"):setup()
|
||||
require("mactag"):setup {
|
||||
-- You can change the colors of the tags here
|
||||
colors = {
|
||||
Red = "#ee7b70",
|
||||
Orange = "#f5bd5c",
|
||||
Yellow = "#fbe764",
|
||||
Green = "#91fc87",
|
||||
Blue = "#5fa3f8",
|
||||
Purple = "#cb88f8",
|
||||
Gray = "#b5b5b9",
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
And register it as fetchers in your `~/.config/yazi/yazi.toml`:
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
local COLORS = { red = "red", yellow = "yellow", orange = "magenta", green = "green", blue = "blue" }
|
||||
|
||||
local update = ya.sync(function(st, tags)
|
||||
for path, tag in pairs(tags) do
|
||||
st.tags[path] = #tag == 0 and nil or tag
|
||||
@@ -18,14 +16,19 @@ local selected_or_hovered = ya.sync(function()
|
||||
return urls
|
||||
end)
|
||||
|
||||
local function setup(st)
|
||||
local function setup(st, opts)
|
||||
st.tags = {}
|
||||
st.colors = opts.colors
|
||||
|
||||
Linemode:children_add(function(self)
|
||||
local url = tostring(self._file.url)
|
||||
local spans = {}
|
||||
for _, tag in ipairs(st.tags[url] or {}) do
|
||||
spans[#spans + 1] = ui.Span("⬤"):fg(COLORS[tag:lower()] or "reset")
|
||||
if self._file:is_hovered() then
|
||||
spans[#spans + 1] = ui.Span("⬤"):bg(st.colors[tag] or "reset")
|
||||
else
|
||||
spans[#spans + 1] = ui.Span("⬤"):fg(st.colors[tag] or "reset")
|
||||
end
|
||||
end
|
||||
return ui.Line(spans)
|
||||
end, 500)
|
||||
|
||||
Reference in New Issue
Block a user