From 4d9f6371ab0a73be77c1ce3255106c3d6f258a02 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Mon, 15 Jan 2024 18:49:40 +0800 Subject: [PATCH] docs: update tips to the latest --- docs/configuration/theme.md | 28 ++++++++----- docs/faq.md | 11 +---- docs/tips.md | 84 ++++++++++--------------------------- 3 files changed, 41 insertions(+), 82 deletions(-) diff --git a/docs/configuration/theme.md b/docs/configuration/theme.md index 9410fc55..8b0b7e09 100644 --- a/docs/configuration/theme.md +++ b/docs/configuration/theme.md @@ -193,21 +193,27 @@ You can restrict the specific type of files through `is`, noting that it must be - `sock`: Socket - `sticky`: File with sticky bit set -## [icons] +## [icon] -Display different icons based on file name rules, noting that the `/` after the name signifies that it must be a directory. +Display icon based on file name rules, noting that the `/` after the name signifies that it's a directory. ```toml -[icons] -"Desktop/" = "" -"*.rs" = "" -# ... - -# Default -"*" = "" -"*/" = "" +[icon] + +rules = [ + { name = "*.rs" , text = "" }, + { name = "Desktop/", text = "" }, + # ... + + # Icon with a color + { name = "*.lua", text = "", fg = "#51a0cf" }, + + # Default + { name = "*" , text = "" }, + { name = "*/", text = "" }, +] ``` -Similarly, `*` and `*/` can be used for fallback matching all files and all directories. +Similarly, `*` and `*/` can be used for fallback matching all files and all directories. You can also use `fg` to set the icon color. The above rules use icons from [Nerd Fonts](https://www.nerdfonts.com), and they will not display properly if you don't have a Nerd Font installed. diff --git a/docs/faq.md b/docs/faq.md index 12a5b55f..e6d55985 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -99,16 +99,9 @@ If you don't want to use it and want things to be calm, sure, you can modify the [status] separator_open = "" separator_close = "" -``` - -and -```toml -[icons] -"Desktop/" = "" -"Documents/" = "" -"Downloads/" = "" -# ... +[icon] +rules = [] ``` The above code changed all icons to `""`, and the whole world went quiet, nice! diff --git a/docs/tips.md b/docs/tips.md index 69189073..a67d1afa 100644 --- a/docs/tips.md +++ b/docs/tips.md @@ -13,63 +13,48 @@ You can implement a full border for Yazi via the UI plugin. -Copy the preset [`Manager:render` function](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/manager.lua) to any place, for example `~/.config/yazi/ui.lua`, then apply the following patch: +Copy the preset [`Manager:render` function](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/manager.lua) to your `~/.config/yazi/init.lua`, then apply the following patch: ```diff -@@ -10,16 +10,28 @@ function Manager:render(area) +@@ -10,16 +10,29 @@ }) :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.Position.TOP ++ ui.Bar.TOP + ):symbol(c) + end + - return utils.flat { -- -- Borders -- ui.Bar(chunks[1], ui.Position.RIGHT):symbol(THEME.manager.border_symbol):style(THEME.manager.border_style), -- ui.Bar(chunks[3], ui.Position.LEFT):symbol(THEME.manager.border_symbol):style(THEME.manager.border_style), -+ ui.Border(area, ui.Position.ALL):type(ui.Border.ROUNDED), -+ ui.Bar(chunks[1], ui.Position.RIGHT), -+ ui.Bar(chunks[3], ui.Position.LEFT), -+ + return ya.flat { + -- Borders +- ui.Bar(chunks[1], ui.Bar.RIGHT):symbol(THEME.manager.border_symbol):style(THEME.manager.border_style), +- ui.Bar(chunks[3], ui.Bar.LEFT):symbol(THEME.manager.border_symbol):style(THEME.manager.border_style), ++ 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 -- Folder:render(chunks[1]:padding(ui.Padding.x(1)), { kind = Folder.PARENT }), -+ Folder:render(chunks[1]:padding(ui.Padding.xy(1)), { kind = Folder.PARENT }), +- Parent:render(chunks[1]:padding(ui.Padding.x(1))), ++ Parent:render(chunks[1]:padding(ui.Padding.xy(1))), -- Current -- Folder:render(chunks[2], { kind = Folder.CURRENT }), -+ Folder:render(chunks[2]:padding(ui.Padding.y(1)), { kind = Folder.CURRENT }), +- Current:render(chunks[2]), ++ Current:render(chunks[2]:padding(ui.Padding.y(1))), -- Preview -- ui.Base(chunks[3]:padding(ui.Padding.x(1)), ui.Base.PREVIEW), -+ ui.Base(chunks[3]:padding(ui.Padding.xy(1)), ui.Base.PREVIEW), +- Preview:render(chunks[3]:padding(ui.Padding.x(1))), ++ Preview:render(chunks[3]:padding(ui.Padding.xy(1))), } end ``` If you prefer sharp corners for the border, you can remove `:type(ui.Border.ROUNDED)`. -Finally include it and adjust the manager layout offset: - -```toml -# yazi.toml -[plugins] -preload = [ - "~/.config/yazi/ui.lua" -] - -# theme.toml -[manager] -folder_offset = [ 2, 0, 2, 0 ] -preview_offset = [ 2, 1, 2, 1 ] -``` - ## Dropping to the shell Add the keybindings to the `[manager]` of `keymap.toml`: @@ -125,7 +110,7 @@ Please make sure that `` does not conflict with your other keys. -Save these lines as a file, for example `~/.config/yazi/ui.lua`: +Add these lines to your `~/.config/yazi/init.lua`: ```lua function Status:render() return {} end @@ -136,27 +121,12 @@ function Manager:render(area) end ``` -Finally include it and adjust the manager layout offset: - -```toml -# yazi.toml -[plugins] -preload = [ - "~/.config/yazi/ui.lua" -] - -# theme.toml -[manager] -folder_offset = [ 1, 0, 0, 0 ] -preview_offset = [ 1, 1, 0, 1 ] -``` - ## Show symlink in status bar -You only need to rewrite the [`Status:name()` method](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/status.lua#L39-L46) to achieve this feature, -save this method as a file, and apply the following patch to it: +You can rewrite the [`Status:name()` method](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/status.lua) to achieve this feature, +copy this method to your `~/.config/yazi/init.lua`, and apply the following patch: ```diff @@ -42,7 +42,11 @@ function Status:name() @@ -172,21 +142,11 @@ save this method as a file, and apply the following patch to it: end ``` -Finally just include it: - -```toml -# yazi.toml -[plugins] -preload = [ - "/path/to/your/status-name-function.lua" -] -``` - ## Show user/group of files in status bar -You only need to rewrite the [`Status:render()` method](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/status.lua#L143-L154) to achieve this feature, +You can rewrite the [`Status:render()` method](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/status.lua) to achieve this feature, copy this method to your `~/.config/yazi/init.lua`, and apply the following patch: ```diff