Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

smart-pane.yazi

Files-only preview on demand. Keep a preview-less default layout, and let l / h open and close the preview pane for files. The preview never opens for directories.

  • l on a file: open the preview pane
  • l on a directory: enter it, closing the preview if it was open
  • h: close the preview if open, otherwise go to the parent directory
  • toggle-preview: one-key preview toggle, e.g. for T

While the preview is open, the parent pane is hidden (default open ratio { 0, 2, 5 }) and the linemode switches to none so the file list shows names only; closing the preview restores both.

The plugin only sets rt.mgr.ratio (it never overrides Tab.layout), so it composes with toggle-pane and the built-in layout.

Installation

ya pkg add tpsteiner/smart-pane

Usage

Hide the preview by default in ~/.config/yazi/yazi.toml:

[mgr]
ratio = [1, 4, 0]

Register the plugin in ~/.config/yazi/init.lua (snapshots the closed layout at startup). open sets the layout while the preview is open (default { 0, 2, 5 }); linemode sets the linemode while the preview is open (default "none", pass false to keep the current one):

require("smart-pane"):setup()
-- or: require("smart-pane"):setup { open = { 1, 2, 5 }, linemode = false }

Add to your ~/.config/yazi/keymap.toml:

[[mgr.prepend_keymap]]
on = "h"
run = "plugin smart-pane leave"
desc = "Close preview / go to parent dir"

[[mgr.prepend_keymap]]
on = "l"
run = "plugin smart-pane enter"
desc = "Enter dir / preview file"

[[mgr.prepend_keymap]]
on = "T"
run = "plugin smart-pane toggle-preview"
desc = "Toggle file preview"

Optionally, disable directory previews entirely so the pane stays empty when a directory is hovered while the preview is open:

[plugin]
prepend_previewers = [
  { url = "*/", run = "noop" },
]

License

This plugin is MIT-licensed. For more information check the LICENSE file.

Shoutout to sxyazi for creating toggle-pane, which this plugin is based on.

About

Yazi file manager plugin to dynamically resize the preview pane while navigating

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages