yazi: update

This commit is contained in:
2025-10-08 21:59:30 +02:00
parent fcb4dfb530
commit e1a02f7994
16 changed files with 982 additions and 1143 deletions

View File

@@ -4,23 +4,20 @@ Simple lualine-like status line for yazi.
Read more about features and configuration [here](#features).
> ⚠️ **Note**:
> If you experience any issues after updating, please refer to the latest release notes. This repository is continuously synced with the upstream Yazi source code, which is actively maintained and frequently updated.
![preview](https://github.com/llanosrocas/yaziline.yazi/blob/master/.github/images/preview.png)
## Requirements
- yazi version >= [25.4.8](https://github.com/sxyazi/yazi/releases/tag/v25.4.8)
- yazi version >= [25.5.28](https://github.com/sxyazi/yazi/releases/tag/v25.5.28)
- Font with symbol support. For example [Nerd Fonts](https://www.nerdfonts.com/).
## Installation
```sh
ya pack -a llanosrocas/yaziline
ya pkg add llanosrocas/yaziline
```
Or manually copy `init.lua` to the `~/.config/yazi/plugins/yaziline.yazi/init.lua`
Or manually copy `main.lua` to the `~/.config/yazi/plugins/yaziline.yazi/main.lua`
## Usage
@@ -35,6 +32,7 @@ Optionally, configure line:
```lua
require("yaziline"):setup({
color = "#98c379", -- main theme color
secondary_color = "#5A6078", -- secondary color
default_files_color = "darkgray", -- color of the file counter when it's inactive
selected_files_color = "white",
yanked_files_color = "green",
@@ -57,6 +55,20 @@ require("yaziline"):setup({
})
```
```
 MODE  size  long_file...name.md  S 0 Y 0
| | | | | | | | |
| | | | | | | | └─── yank_symbol
| | | | | | | └─────── select_symbol
| | | | | | └───────── separator_close_thin
| | | | | └─────────────────── filename_truncate_separator
| | | | └─────────────────────────────── separator_close
| | | └────────────────────────────────── secondary_color
| | └────────────────────────────────────── separator_close
| └────────────────────────────────────────── color
└───────────────────────────────────────────── separator_head
```
## Features
### Preconfigured separators

View File

@@ -1,3 +1,5 @@
---@diagnostic disable: undefined-global
local function setup(_, options)
options = options or {}
@@ -26,6 +28,7 @@ local function setup(_, options)
filename_truncate_separator = options.filename_truncate_separator or "...",
color = options.color or nil,
secondary_color = options.secondary_color or nil,
default_files_color = options.default_files_color
or th.which.separator_style.fg
or "darkgray",
@@ -61,12 +64,12 @@ local function setup(_, options)
function Status:size()
local h = self._current.hovered
local size = h and ya.readable_size(h:size() or h.cha.len)
local size = h and (h:size() or h.cha.len) or 0
local style = self:style()
return ui.Span(current_separator_style.separator_close .. " " .. size .. " ")
return ui.Span(current_separator_style.separator_close .. " " .. ya.readable_size(size) .. " ")
:fg(config.color or style.main.bg)
:bg(th.which.separator_style.fg)
:bg(config.secondary_color or th.which.separator_style.fg)
end
function Status:utf8_sub(str, start_char, end_char)
@@ -95,21 +98,26 @@ local function setup(_, options)
end
function Status:name()
local h = self._current.hovered
if not h then
return ""
end
local h = self._current.hovered
if not h then
return ui.Line({
ui.Span(current_separator_style.separator_close .. " ")
:fg(config.secondary_color or th.which.separator_style.fg),
ui.Span("Empty dir")
:fg(config.color or style.main.bg),
})
end
local truncated_name = self:truncate_name(h.name, config.filename_max_length)
local truncated_name = self:truncate_name(h.name, config.filename_max_length)
local style = self:style()
return ui.Line {
ui.Span(current_separator_style.separator_close .. " ")
:fg(th.which.separator_style.fg),
ui.Span(truncated_name)
local style = self:style()
return ui.Line({
ui.Span(current_separator_style.separator_close .. " ")
:fg(config.secondary_color or th.which.separator_style.fg),
ui.Span(truncated_name)
:fg(config.color or style.main.bg),
}
end
})
end
function Status:files()
local files_yanked = #cx.yanked
@@ -134,7 +142,7 @@ local function setup(_, options)
return ui.Line({
ui.Span(" " .. current_separator_style.separator_close_thin .. " ")
:fg(th.which.separator_style.fg),
ui.Span(config.select_symbol .. " " .. files_selected .. " ")
ui.Span(config.select_symbol .. " " .. files_selected .. " ")
:fg(selected_fg),
ui.Span(yanked_text .. " ")
:fg(yanked_fg),
@@ -143,6 +151,11 @@ local function setup(_, options)
function Status:modified()
local hovered = cx.active.current.hovered
if not hovered then
return ""
end
local cha = hovered.cha
local time = (cha.mtime or 0) // 1
@@ -168,14 +181,14 @@ local function setup(_, options)
local style = self:style()
return ui.Line({
ui.Span(" " .. current_separator_style.separator_open)
:fg(th.which.separator_style.fg),
ui.Span(" " .. current_separator_style.separator_open)
:fg(config.secondary_color or th.which.separator_style.fg),
ui.Span(percent)
:fg(config.color or style.main.bg)
:bg(th.which.separator_style.fg),
:bg(config.secondary_color or th.which.separator_style.fg),
ui.Span(current_separator_style.separator_open)
:fg(config.color or style.main.bg)
:bg(th.which.separator_style.fg),
:bg(config.secondary_color or th.which.separator_style.fg),
})
end