diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-11 11:46:09 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-11 11:46:09 +0900 |
| commit | 8c0fe8d0d0dd4bbd16c1095e25b2e3ffa1fdb0d3 (patch) | |
| tree | 597b8dfd730eda9b410fb6082b0bee7fcc7e70e2 /fedora/.config/yazi/plugins/toggle-pane.yazi | |
| parent | 74713d79880967f5f0f8652c6741bc5fa63a8794 (diff) | |
updates
Diffstat (limited to 'fedora/.config/yazi/plugins/toggle-pane.yazi')
| -rw-r--r-- | fedora/.config/yazi/plugins/toggle-pane.yazi/README.md | 78 | ||||
| -rw-r--r-- | fedora/.config/yazi/plugins/toggle-pane.yazi/main.lua | 45 |
2 files changed, 123 insertions, 0 deletions
diff --git a/fedora/.config/yazi/plugins/toggle-pane.yazi/README.md b/fedora/.config/yazi/plugins/toggle-pane.yazi/README.md new file mode 100644 index 0000000..3ef4095 --- /dev/null +++ b/fedora/.config/yazi/plugins/toggle-pane.yazi/README.md @@ -0,0 +1,78 @@ +# toggle-pane.yazi + +Toggle the show, hide, and maximize states for different panes: parent, current, and preview. It respects the user's [`ratio` settings](https://yazi-rs.github.io/docs/configuration/yazi#mgr.ratio)! + +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 pkg add yazi-rs/plugins:toggle-pane +``` + +## Usage + +Hide/Show preview: + +```toml +# keymap.toml +[[mgr.prepend_keymap]] +on = "T" +run = "plugin toggle-pane min-preview" +desc = "Show or hide the preview pane" +``` + +Maximize/Restore preview: + +```toml +# keymap.toml +[[mgr.prepend_keymap]] +on = "T" +run = "plugin toggle-pane max-preview" +desc = "Maximize or restore the preview pane" +``` + +You can replace `preview` with `current` or `parent` to toggle the other panes. + +## 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-pane"):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. + +## Tips + +This plugin only maximizes the "available preview area", without actually changing the content size. + +This means that the appearance of your preview largely depends on the previewer you are using. +However, most previewers tend to make the most of the available space, so this usually isn't an issue. + +For image previews, you may want to tune up the [`max_width`][max-width] and [`max_height`][max-height] options in your `yazi.toml`: + +```toml +[preview] +# Change them to your desired values +max_width = 1000 +max_height = 1000 +``` + +[max-width]: https://yazi-rs.github.io/docs/configuration/yazi/#preview.max_width +[max-height]: https://yazi-rs.github.io/docs/configuration/yazi/#preview.max_height + +## License + +This plugin is MIT-licensed. For more information, check the [LICENSE](LICENSE) file. diff --git a/fedora/.config/yazi/plugins/toggle-pane.yazi/main.lua b/fedora/.config/yazi/plugins/toggle-pane.yazi/main.lua new file mode 100644 index 0000000..72bbf0e --- /dev/null +++ b/fedora/.config/yazi/plugins/toggle-pane.yazi/main.lua @@ -0,0 +1,45 @@ +--- @since 25.5.31 +--- @sync entry + +local function entry(st, job) + local R = rt.mgr.ratio + job = type(job) == "string" and { args = { job } } or job + + st.parent = st.parent or R.parent + st.current = st.current or R.current + st.preview = st.preview or R.preview + + local act, to = string.match(job.args[1] or "", "(.-)-(.+)") + if act == "min" then + st[to] = st[to] == R[to] and 0 or R[to] + elseif act == "max" then + local max = st[to] == 65535 and R[to] or 65535 + st.parent = st.parent == 65535 and R.parent or st.parent + st.current = st.current == 65535 and R.current or st.current + st.preview = st.preview == 65535 and R.preview or st.preview + st[to] = max + end + + if not st.old then + st.old = Tab.layout + Tab.layout = function(self) + local all = st.parent + st.current + st.preview + self._chunks = ui.Layout() + :direction(ui.Layout.HORIZONTAL) + :constraints({ + ui.Constraint.Ratio(st.parent, all), + ui.Constraint.Ratio(st.current, all), + ui.Constraint.Ratio(st.preview, all), + }) + :split(self._area) + end + end + + if not act then + Tab.layout, st.old = st.old, nil + st.parent, st.current, st.preview = nil, nil, nil + end + ya.emit("app:resize", {}) +end + +return { entry = entry } |
