♻️ refactor(yazi): changes to adapt to the new breaking changes in 0.20 release
This commit is contained in:
parent
fd7b7e7a83
commit
8e739d64de
5 changed files with 70 additions and 80 deletions
66
.config/yazi/init.lua
Normal file
66
.config/yazi/init.lua
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
-- Border
|
||||||
|
function Manager:render(area)
|
||||||
|
self.area = area
|
||||||
|
|
||||||
|
local chunks = ui.Layout()
|
||||||
|
:direction(ui.Layout.HORIZONTAL)
|
||||||
|
:constraints({
|
||||||
|
ui.Constraint.Ratio(MANAGER.ratio.parent, MANAGER.ratio.all),
|
||||||
|
ui.Constraint.Ratio(MANAGER.ratio.current, MANAGER.ratio.all),
|
||||||
|
ui.Constraint.Ratio(MANAGER.ratio.preview, MANAGER.ratio.all),
|
||||||
|
})
|
||||||
|
:split(area)
|
||||||
|
|
||||||
|
local bar = function(c, x, y)
|
||||||
|
return ui.Bar(
|
||||||
|
ui.Rect({ x = math.max(0, x), y = math.max(0, y), w = math.min(1, area.w), h = math.min(1, area.h) }),
|
||||||
|
ui.Bar.TOP
|
||||||
|
):symbol(c)
|
||||||
|
end
|
||||||
|
|
||||||
|
return ya.flat({
|
||||||
|
-- Borders
|
||||||
|
ui.Border(area, ui.Border.ALL):type(ui.Border.ROUNDED),
|
||||||
|
ui.Bar(chunks[1], ui.Bar.RIGHT),
|
||||||
|
ui.Bar(chunks[3], ui.Bar.LEFT),
|
||||||
|
|
||||||
|
bar("┬", chunks[1].right - 1, chunks[1].y),
|
||||||
|
bar("┴", chunks[1].right - 1, chunks[1].bottom - 1),
|
||||||
|
bar("┬", chunks[2].right, chunks[2].y),
|
||||||
|
bar("┴", chunks[2].right, chunks[1].bottom - 1),
|
||||||
|
|
||||||
|
-- Parent
|
||||||
|
Parent:render(chunks[1]:padding(ui.Padding.xy(1))),
|
||||||
|
-- Current
|
||||||
|
Current:render(chunks[2]:padding(ui.Padding.y(1))),
|
||||||
|
-- Preview
|
||||||
|
Preview:render(chunks[3]:padding(ui.Padding.xy(1))),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Show user/group of files in status bar
|
||||||
|
function Status:owner()
|
||||||
|
local h = cx.active.current.hovered
|
||||||
|
if h == nil or ya.target_family() ~= "unix" then
|
||||||
|
return ui.Line({})
|
||||||
|
end
|
||||||
|
|
||||||
|
return ui.Line({
|
||||||
|
ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)):fg("magenta"),
|
||||||
|
ui.Span(":"),
|
||||||
|
ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)):fg("magenta"),
|
||||||
|
ui.Span(" "),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function Status:render(area)
|
||||||
|
self.area = area
|
||||||
|
|
||||||
|
local left = ui.Line({ self:mode(), self:size(), self:name() })
|
||||||
|
local right = ui.Line({ self:owner(), self:permissions(), self:percentage(), self:position() })
|
||||||
|
return {
|
||||||
|
ui.Paragraph(area, { left }),
|
||||||
|
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
|
||||||
|
table.unpack(Progress:render(area, right:width())),
|
||||||
|
}
|
||||||
|
end
|
|
@ -1,12 +0,0 @@
|
||||||
function Status:name()
|
|
||||||
local h = cx.active.current.hovered
|
|
||||||
if h == nil then
|
|
||||||
return ui.Span("")
|
|
||||||
end
|
|
||||||
|
|
||||||
local linked = ""
|
|
||||||
if h.link_to ~= nil then
|
|
||||||
linked = " -> " .. tostring(h.link_to)
|
|
||||||
end
|
|
||||||
return ui.Span(" " .. h.name .. linked)
|
|
||||||
end
|
|
|
@ -1,11 +1,6 @@
|
||||||
# vim:fileencoding=utf-8:foldmethod=marker
|
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
|
||||||
|
|
||||||
# : Manager {{{
|
|
||||||
|
|
||||||
[manager]
|
[manager]
|
||||||
folder_offset = [2, 0, 2, 0]
|
|
||||||
preview_offset = [2, 1, 2, 1]
|
|
||||||
|
|
||||||
cwd = { fg = "#8bd5ca" }
|
cwd = { fg = "#8bd5ca" }
|
||||||
|
|
||||||
# Hovered
|
# Hovered
|
||||||
|
@ -33,10 +28,6 @@ border_style = { fg = "#8087a2" }
|
||||||
# Highlighting
|
# Highlighting
|
||||||
syntect_theme = "~/.config/bat/themes/Catppuccin-macchiato.tmTheme"
|
syntect_theme = "~/.config/bat/themes/Catppuccin-macchiato.tmTheme"
|
||||||
|
|
||||||
# : }}}
|
|
||||||
|
|
||||||
|
|
||||||
# : Status {{{
|
|
||||||
|
|
||||||
[status]
|
[status]
|
||||||
separator_open = ""
|
separator_open = ""
|
||||||
|
@ -60,10 +51,6 @@ permissions_w = { fg = "#ed8796" }
|
||||||
permissions_x = { fg = "#a6da95" }
|
permissions_x = { fg = "#a6da95" }
|
||||||
permissions_s = { fg = "#8087a2" }
|
permissions_s = { fg = "#8087a2" }
|
||||||
|
|
||||||
# : }}}
|
|
||||||
|
|
||||||
|
|
||||||
# : Input {{{
|
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
border = { fg = "#8aadf4" }
|
border = { fg = "#8aadf4" }
|
||||||
|
@ -71,30 +58,18 @@ title = {}
|
||||||
value = {}
|
value = {}
|
||||||
selected = { reversed = true }
|
selected = { reversed = true }
|
||||||
|
|
||||||
# : }}}
|
|
||||||
|
|
||||||
|
|
||||||
# : Select {{{
|
|
||||||
|
|
||||||
[select]
|
[select]
|
||||||
border = { fg = "#8aadf4" }
|
border = { fg = "#8aadf4" }
|
||||||
active = { fg = "#f5bde6" }
|
active = { fg = "#f5bde6" }
|
||||||
inactive = {}
|
inactive = {}
|
||||||
|
|
||||||
# : }}}
|
|
||||||
|
|
||||||
|
|
||||||
# : Tasks {{{
|
|
||||||
|
|
||||||
[tasks]
|
[tasks]
|
||||||
border = { fg = "#8aadf4" }
|
border = { fg = "#8aadf4" }
|
||||||
title = {}
|
title = {}
|
||||||
hovered = { underline = true }
|
hovered = { underline = true }
|
||||||
|
|
||||||
# : }}}
|
|
||||||
|
|
||||||
|
|
||||||
# : Which {{{
|
|
||||||
|
|
||||||
[which]
|
[which]
|
||||||
mask = { bg = "#363a4f" }
|
mask = { bg = "#363a4f" }
|
||||||
|
@ -116,10 +91,6 @@ desc = { fg = "#939ab7" }
|
||||||
hovered = { bg = "#5b6078", bold = true }
|
hovered = { bg = "#5b6078", bold = true }
|
||||||
footer = { fg = "#494d64", bg = "#cad3f5" }
|
footer = { fg = "#494d64", bg = "#cad3f5" }
|
||||||
|
|
||||||
# : }}}
|
|
||||||
|
|
||||||
|
|
||||||
# : File-specific styles {{{
|
|
||||||
|
|
||||||
[filetype]
|
[filetype]
|
||||||
|
|
||||||
|
@ -144,5 +115,3 @@ rules = [
|
||||||
{ name = "*", fg = "#cad3f5" },
|
{ name = "*", fg = "#cad3f5" },
|
||||||
{ name = "*/", fg = "#8aadf4" },
|
{ name = "*/", fg = "#8aadf4" },
|
||||||
]
|
]
|
||||||
|
|
||||||
# : }}}
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
function Manager:render(area)
|
|
||||||
local chunks = ui.Layout()
|
|
||||||
:direction(ui.Direction.HORIZONTAL)
|
|
||||||
:constraints({
|
|
||||||
ui.Constraint.Ratio(MANAGER.layout.parent, MANAGER.layout.all),
|
|
||||||
ui.Constraint.Ratio(MANAGER.layout.current, MANAGER.layout.all),
|
|
||||||
ui.Constraint.Ratio(MANAGER.layout.preview, MANAGER.layout.all),
|
|
||||||
})
|
|
||||||
:split(area)
|
|
||||||
|
|
||||||
local bar = function(c, x, y)
|
|
||||||
return ui.Bar(ui.Rect({ x = math.max(0, x), y = math.max(0, y), w = 1, h = 1 }), ui.Position.TOP):symbol(c)
|
|
||||||
end
|
|
||||||
|
|
||||||
return utils.flat({
|
|
||||||
ui.Border(area, ui.Position.ALL):type(ui.Border.ROUNDED),
|
|
||||||
ui.Bar(chunks[1], ui.Position.RIGHT),
|
|
||||||
ui.Bar(chunks[3], ui.Position.LEFT),
|
|
||||||
|
|
||||||
bar("┬", chunks[1].right - 1, chunks[1].y),
|
|
||||||
bar("┴", chunks[1].right - 1, chunks[1].bottom - 1),
|
|
||||||
bar("┬", chunks[2].right, chunks[2].y),
|
|
||||||
bar("┴", chunks[2].right, chunks[1].bottom - 1),
|
|
||||||
|
|
||||||
-- Parent
|
|
||||||
Folder:render(chunks[1]:padding(ui.Padding.xy(1)), { kind = Folder.PARENT }),
|
|
||||||
-- Current
|
|
||||||
Folder:render(chunks[2]:padding(ui.Padding.y(1)), { kind = Folder.CURRENT }),
|
|
||||||
-- Preview
|
|
||||||
ui.Base(chunks[3]:padding(ui.Padding.xy(1)), ui.Base.PREVIEW),
|
|
||||||
})
|
|
||||||
end
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
"$schema" = "https://yazi-rs.github.io/schemas/yazi.json"
|
||||||
|
|
||||||
[manager]
|
[manager]
|
||||||
layout = [1, 4, 3]
|
ratio = [1, 4, 3]
|
||||||
sort_by = "natural"
|
sort_by = "natural"
|
||||||
sort_reverse = false
|
sort_reverse = false
|
||||||
sort_dir_first = true
|
sort_dir_first = true
|
||||||
|
@ -73,6 +75,3 @@ bizarre_retry = 5
|
||||||
|
|
||||||
[log]
|
[log]
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[plugins]
|
|
||||||
preload = ["~/.config/yazi/ui.lua", "~/.config/yazi/symlink.lua"]
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue