Closed zuqini closed 4 months ago
Do you experience the same problem with the following command?
:call fzf#run(fzf#wrap({'options': ['--preview', 'cat {}']}))
Nope, that works!
Same here. I could confirm that following works with vim in bash terminal.
:call fzf#run(fzf#wrap({'options': ['--preview', 'cat {}']}))
But in gvim cat is unavailable, so still no preview there.
I don't have a Windows PC to debug and test this on. Pull requests are welcome.
It seems I've found a workaround. Although it's not even a workaround, but rather an improvement of the default preview situation, and it's mentioned right in the README of fzf.vim 🫠.
You need to install bat. A tool that, as far as I understand, replaces cat and adds syntax highlighting in the preview window. I just unpacked the archive with the bat binary and added this path to my path. After that, the preview window began to display the contents of the selected files.
How did you get the syntax highlighting to work in the preview window?
How did you get the syntax highlighting to work in the preview window?
I literally did nothing except install bat. Just make sure the folder with the bat executable is available in the PATH so that fzf.vim can find it.
Fixed in d91dd754a933e3da9797253f9b6d268bb85d0f4d.
And yeah, having bat would avoid the bug.
man fzf
)Info
Problem / Steps to reproduce
Preview window is not showing file content for nested paths that include backslashes (e.g.
after\ftplugin\lua.vim
as opposed tolua.vim
. vs.It looks like it's caused by
bash
not interpreting the unescaped\
from the path returned byfzf.vim\bin\preview.sh
.Reproduce directly with fzf by:
fzf --preview='bash {...}\.vim\plugged\fzf.vim\bin\preview.sh {}' --bind shift-up:preview-page-up,shift-down:preview-page-down
To further debug the problem, I logged the command returned by
preview.sh
and ran it in bash directly and saw that the backslash was swallowed:If I escape the path, then it previews the file content successfully:
Environment
This is happening on a new Windows 11 installation:
The vim version shouldn't matter since I reproduced the issue directly with
preview.sh
, but here it is anyway in case it helps:The
bash.exe
points to the git bash installed fromscoop
:C:\Users\{username}\scoop\apps\git\current\bin\bash.exe
I should note that this did not happen prior to my Windows 11 re-install. I have no idea what changed that suddenly caused this issue. Appreciate any pointers!