Skip to content

Commit

Permalink
docs: add append_previewers example
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Feb 20, 2024
1 parent caed002 commit 52d86bd
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 43 deletions.
79 changes: 42 additions & 37 deletions docs/configuration/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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.
Expand All @@ -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.

Expand All @@ -216,7 +221,7 @@ prepend_rules = [
]

append_rules = [
# Default
# My fallback icons
{ name = "*" , text = "" },
{ name = "*/", text = "" },
]
Expand All @@ -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.
11 changes: 9 additions & 2 deletions docs/configuration/yazi.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,24 @@ 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]
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
Expand Down
8 changes: 4 additions & 4 deletions docs/plugins/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 52d86bd

Please sign in to comment.