junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
65.33k stars 2.4k forks source link

Use a neovim window for preview when fzf is run in neovim #1078

Closed mrbiggfoot closed 7 years ago

mrbiggfoot commented 7 years ago

It would be nice to have a native option to preview in a neovim window if fzf is executed in neovim terminal. Currently I use a hack that calls a python script from --preview command. That script communicates with neovim using "neovim" module and calls a vim script function to open a preview window. Looks like the python dependency can be eliminated. It should also be faster and less hacky :)

janlazo commented 7 years ago

You want the fzf binary to not use its preview split and instead script neovim to open a buffer and do something via viml? This is all done without python dependencies, msgpack, and neovim-remote?

mrbiggfoot commented 7 years ago

fzf could check for NVIM_LISTEN_ADDRESS env var and use msgpack (that's what neovim's interface uses if I'm not mistaken) to communicate with neovim. A vim script function to open the preview window could be implemented in fzf.vim plugin. I don't see where python is needed in this scheme.

janlazo commented 7 years ago

This is not possible via rpc in termopen?

mrbiggfoot commented 7 years ago

@janlazo you mean, create a preview window using termopen()? That's bad because neovim's coloring/editing capabilites won't work for the preview window. Or you mean something else?

janlazo commented 7 years ago

This one https://github.com/junegunn/fzf/blob/master/plugin/fzf.vim#L700

rpc is mentioned :h jobstart which refers to :h msgpack-rpc

mrbiggfoot commented 7 years ago

If I understand correctly, it's just a way of communication between fzf and neovim... using msgpack over stdin/stdout instead of a socket on NVIM_LISTEN_ADDRESS, correct? I guess it would work too. But there should still be some support in neovim, like: 1) closing the preview window when fzf terminal is closed; 2) closing the file being previewed when the next file is opened for preview, etc. Please let me know if it can be easily done without a dedicated VimL function.

junegunn commented 7 years ago

Thanks for the suggestion, but this is definitely not what I want in fzf. I'll never want to implement and maintain extra code for all kinds of external programs (there's nothing special about Neovim and I don't even use it) which will make fzf more complex and less stable.

mrbiggfoot commented 7 years ago

I see your point. Though, IIUC the main burden would be on fzf.vim, and the change to fzf would be minimal and non-intrusive. Ok, I'll go on with my own hack.