From 52d86bd45c40374f5ad9d76b897732ddc3f6ea25 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Tue, 20 Feb 2024 19:28:40 +0800 Subject: [PATCH] docs: add `append_previewers` example --- docs/configuration/theme.md | 79 ++++++++++++++++++++----------------- docs/configuration/yazi.md | 11 +++++- docs/plugins/layout.md | 8 ++-- 3 files changed, 55 insertions(+), 43 deletions(-) diff --git a/docs/configuration/theme.md b/docs/configuration/theme.md index 18b19d61..30ce25e0 100644 --- a/docs/configuration/theme.md +++ b/docs/configuration/theme.md @@ -11,38 +11,43 @@ If you're looking for ready-made themes and don't want to create one yourself, c ## Types -- Color: A color. It can be in Hex format with RGB values, such as `#484D66`. Or can be one of the following 17 values: - - - reset - - black - - white - - red - - lightred - - green - - lightgreen - - yellow - - lightyellow - - blue - - lightblue - - magenta - - lightmagenta - - cyan - - lightcyan - - gray - - darkgray - -- Style: Appears in a format similar to `{ fg = "#e4e4e4", bg = "black", ... }`, and supports the following properties: - - fg (Color): Foreground color - - bg (Color): Background color - - bold (Boolean): Bold - - dim (Boolean): Dim (not supported by all terminals) - - italic (Boolean): Italic - - underline (Boolean): Underline - - blink (Boolean): Blink - - blink_rapid (Boolean): Rapid blink - - reversed (Boolean): Reversed foreground and background colors - - hidden (Boolean): Hidden - - crossed (Boolean): Crossed out +### Color + +A color. It can be in Hex format with RGB values, such as `#484D66`. Or can be one of the following 17 values: + +- reset +- black +- white +- red +- lightred +- green +- lightgreen +- yellow +- lightyellow +- blue +- lightblue +- magenta +- lightmagenta +- cyan +- lightcyan +- gray +- darkgray + +### Style + +Appears in a format similar to `{ fg = "#e4e4e4", bg = "black", ... }`, and supports the following properties: + +- fg (Color): Foreground color +- bg (Color): Background color +- bold (Boolean): Bold +- dim (Boolean): Dim (not supported by all terminals) +- italic (Boolean): Italic +- underline (Boolean): Underline +- blink (Boolean): Blink +- blink_rapid (Boolean): Rapid blink +- reversed (Boolean): Reversed foreground and background colors +- hidden (Boolean): Hidden +- crossed (Boolean): Crossed out ## [manager] @@ -182,7 +187,7 @@ rules = [ ] ``` -Each rule supports complete [Style properties](#types). There are two special rule: +Each rule supports complete [Style properties](#style). There are two special rule: - `name = "*"` matches all files. - `name = "*/"` matches all directories. @@ -200,7 +205,7 @@ You can restrict the specific type of files through `is`, noting that it must be ## [icon] -Display icon based on the first matched rule, noting that end with `/` for directories. +Display icon based on the first matched rule. You can prepend or append rules to the default through `prepend_rules` and `append_rules`, see [Configuration mixing](/docs/configuration/overview#configuration-mixing) for details. @@ -216,7 +221,7 @@ prepend_rules = [ ] append_rules = [ - # Default + # My fallback icons { name = "*" , text = "" }, { name = "*/", text = "" }, ] @@ -231,6 +236,6 @@ rules = [ ] ``` -Similarly, `*` and `*/` can be used for fallback matching all files and all directories. You can also use `fg` to set the icon color. +End with `/` for directories, so wildcard rule (`*` or `*/`) can be used for fallback matching all files or directories. -The example above use icons from [Nerd Fonts](https://www.nerdfonts.com), and they will not display properly if you don't have a Nerd Font installed. +If your `append_rules` contains wildcard rules, they will always take precedence over the default wildcard rules as the fallback. diff --git a/docs/configuration/yazi.md b/docs/configuration/yazi.md index 7582b5c8..d92c0a9b 100644 --- a/docs/configuration/yazi.md +++ b/docs/configuration/yazi.md @@ -222,8 +222,8 @@ Here are the available options for a single rule: - `name` (String): Glob expression for matching the file name. Case insensitive by default, add `\s` to the beginning to make it sensitive. - `mime` (String): Glob expression for matching the mime-type. Case insensitive by default, add `\s` to the beginning to make it sensitive. -- `exec` (String): The name of the Lua plugin to be executed -- `sync` (Boolean): Whether to execute synchronously, the default is `false` +- `exec` (String): The name of the Lua plugin to be executed. +- `sync` (Boolean): Whether to execute in the sync context, default is `false`. ```toml [plugin] @@ -231,8 +231,15 @@ prepend_previewers = [ # HEIC previewer { mime = "image/heic", exec = "heic" }, ] + +append_previewers = [ + # My fallback previewer + { name = "*" , exec = "binary" }, +] ``` +If your `append_rules` contains wildcard `name` rules (`"*"` or `"*/"`), they will always take precedence over the default wildcard rules as the fallback. + Yazi comes with the these previewer plugins: - folder: bridge between the Yazi file system and the preview diff --git a/docs/plugins/layout.md b/docs/plugins/layout.md index 1298bba7..ddc1b319 100644 --- a/docs/plugins/layout.md +++ b/docs/plugins/layout.md @@ -243,8 +243,8 @@ ui.Span("string") Methods (all methods return `self`): -- `ui.Span:fg(color)` - Set the foreground color of the span, which accepts a [Color](../configuration/theme.md#types) -- `ui.Span:bg(color)` - Set the background color of the span, which accepts a [Color](../configuration/theme.md#types) +- `ui.Span:fg(color)` - Set the foreground color of the span, which accepts a [Color](../configuration/theme.md#color) +- `ui.Span:bg(color)` - Set the background color of the span, which accepts a [Color](../configuration/theme.md#color) - `ui.Span:bold()` - Set the span to bold - `ui.Span:dim()` - Set the span to dim - `ui.Span:italic()` - Set the span to italic @@ -264,8 +264,8 @@ Create a style: ui.Style() ``` -- `ui.Style:fg(string)` - Set the foreground color of the style, which accepts a [Color](../configuration/theme.md#types) -- `ui.Style:bg(string)` - Set the background color of the style, which accepts a [Color](../configuration/theme.md#types) +- `ui.Style:fg(string)` - Set the foreground color of the style, which accepts a [Color](../configuration/theme.md#color) +- `ui.Style:bg(string)` - Set the background color of the style, which accepts a [Color](../configuration/theme.md#color) - `ui.Style:bold()` - Set the style to bold - `ui.Style:dim()` - Set the style to dim - `ui.Style:italic()` - Set the style to italic