58 lines
2.0 KiB
Markdown
58 lines
2.0 KiB
Markdown
# toggle-view.yazi
|
|
|
|
Based on the user's [`ratio` configuration](https://yazi-rs.github.io/docs/configuration/yazi#manager.ratio), toggles the minimum and maximum width for each column view.
|
|
|
|
Assume the user's `ratio` is $$[A, B, C]$$, that is, $$\text{parent}=A, \text{current}=B, \text{preview}=C$$:
|
|
|
|
- `min-parent`: Toggles between $$0$$ and $$A$$ - the parent is either completely hidden or showed with width $$A$$.
|
|
- `max-parent`: Toggles between $$A$$ and $$\infty$$ - the parent is either showed with width $$A$$ or fills the entire screen.
|
|
- `min-current`: Toggles between $$0$$ and $$B$$ - the current is either completely hidden or showed with width $$B$$.
|
|
- `max-current`: Toggles between $$B$$ and $$\infty$$ - the current is either showed with width $$B$$ or fills the entire screen.
|
|
- `min-preview`: Toggles between $$0$$ and $$C$$ - the preview is either completely hidden or showed with width $$C$$.
|
|
- `max-preview`: Toggles between $$C$$ and $$\infty$$ - the preview is either showed with width $$C$$ or fills the entire screen.
|
|
- `reset`: Resets to the user's configured `ratio`.
|
|
|
|
## Installation
|
|
|
|
```sh
|
|
ya pack -a yazi-rs/plugins:full-border
|
|
```
|
|
|
|
## Usage
|
|
|
|
Hide/Show preview:
|
|
|
|
```toml
|
|
[[manager.prepend_keymap]]
|
|
on = "T"
|
|
run = "plugin toggle-view min-preview"
|
|
desc = "Show/Hide preview"
|
|
```
|
|
|
|
Maximize/Restore preview:
|
|
|
|
```toml
|
|
[[manager.prepend_keymap]]
|
|
on = "T"
|
|
run = "plugin toggle-view max-preview"
|
|
desc = "Maximize/Restore preview"
|
|
```
|
|
|
|
You can replace `preview` with `current` or `parent` to toggle the other columns.
|
|
|
|
## Advanced
|
|
|
|
In addition to triggering the plugin with a keypress, you can also trigger it in your `init.lua` file:
|
|
|
|
```lua
|
|
if os.getenv("NVIM") then
|
|
require("toggle-view"):entry("min-preview")
|
|
end
|
|
```
|
|
|
|
In the example above, when it detects that you're [using Yazi in nvim](https://yazi-rs.github.io/docs/resources#vim), the preview is hidden by default — you can always press `T` (or any key you've bound) to show it again.
|
|
|
|
## License
|
|
|
|
This plugin is MIT-licensed. For more information, check the [LICENSE](LICENSE) file.
|