broot icon indicating copy to clipboard operation
broot copied to clipboard

Transformers without output?

Open n0bra1n3r opened this issue 1 year ago • 4 comments

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.

n0bra1n3r avatar Sep 13 '24 01:09 n0bra1n3r

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) ?

Canop avatar Sep 13 '24 07:09 Canop

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.

n0bra1n3r avatar Sep 13 '24 23:09 n0bra1n3r

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/ )

Canop avatar Sep 14 '24 05:09 Canop

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.

n0bra1n3r avatar Sep 14 '24 23:09 n0bra1n3r