Canop / broot

A new way to see and navigate directory trees : https://dystroy.org/broot
MIT License
10.74k stars 235 forks source link

Transformers without output? #943

Open n0bra1n3r opened 1 month ago

n0bra1n3r commented 1 month ago

Hello, I was wondering if it's possible to use preview transformers without any output, and just run an external command whenever a preview should be rendered (for both directories and files)? I was thinking something like:

[[preview_transformers]]
  input_extensions = [ "*" ]
  mode = "none"
  command = [
    "nvim",
    "--server",
    "$NVIM",
    "--remote-expr",
    "v:lua.fn.open_explorer_preview(\"{file}\")",
  ]

I wanted this to call into the remote neovim instance and show a preview for a file inside neovim itself.

Canop commented 1 month ago

You mean you want to display nvim in the preview panel, or just that you want to run that command (which then doesn't really involve previews or preview transformers) ?

n0bra1n3r commented 1 month ago

Yes I just want to run the command. If there is an existing mechanism to run a command when a preview should be rendered that would be ideal.

Canop commented 1 month ago

Well, you can always override the preview key shortcut:

{
    key: ctrl-right
    external: "nvim +{line} {file}"
    extensions: ["md", "rs"]
    leave_broot: false
}

but you'll miss many features of broot, for example when searching (see https://dystroy.org/blog/broot-c-search/ )

n0bra1n3r commented 1 month ago

I see. I also just tried overriding the up and down keys with a cmd, but ya that still doesn't cover preview after a search.

Would be really cool to be able to "hook" into features like this to completely customise behavior of broot.