junegunn / fzf.vim

fzf :heart: vim
MIT License
9.55k stars 583 forks source link

Preview window not coloured in Windows Terminal #1414

Closed guntern closed 2 years ago

guntern commented 2 years ago

I just tried to configure vim (8.2) and neovim (0.7.2). I am using fzf 0.32 and the latest versions of the fzf plugin and fzf.vim plugin for vim. I also installed bat 0.21. Under Windows also git for windows with the corresponding bash ist installed.

Under Ubuntu 20.04 inside a WSL 2 it works like a charme.

Unfortunately I did not get the coloured preview output inside windows terminal under Windows 10. I checked that it actually uses bat. First of all I noticed for pdf files a warning from bat. Second I edited the preview.sh to create some debug output. And this all indicates that bat is used and should show colors, but there are none. bat works wonderful inside powershell in the windows terminal. Also the rest of my vim is coloured as I like (OneHalfDark). I also added the configuration file for bat to also specifiy OneHalfDark as theme there.

When running vim in the git bash, the search results and preview are opened as new window an the output is coloured. Neovim did not start in the git bash.

When running vim in cmder the whole thing is unsuably slow and there is no colour, even though I have seen it in my first attempt, but double checking now it is not working anymore.

When running neovim in cmder it is still slow, but I see at least some colour. There are other issues (no border of the preview window), but there would be syntax highlighting.

So all these tests show, that basically everything should be there and more or less running. But what am I missing to get the syntax highlighting in the preview window in vim/neovim inside the windows terminal?

guntern commented 2 years ago

Working through man fzf I also tried the following line in powershell inside windows terminal fzf --preview='bat --color=always {}' This shows a coloured output as I would also expect it inside of vim/neovim.

Digging through the vim.vim of the plugin I checked the command, which is run for the preview. So I then ran bash preview.sh somefile inside of powershell and received a coloured output.

guntern commented 2 years ago

I figured it out at least for neovim in powershell, which is my main use case. It turns out it is neither a problem with fzf.vim nor the windows terminal as I suspected. I had to use set termguicolors in the init.vim for neovim. It was a long route of digging to find that.

vim in Windows Terminal also shows colors now. I am not sure if I changed anything while trying to figure out the problem. Surprisingly the background of the preview is blue. But as I use neovim normally, I don't care. The preview window is also very slow in vim. Probably I just experienced the reason why neovim actually exists.

It also works in cmder for vim and neovim. Even though there was some strange behavior in the first try. But as I just pulled up cmder for testing purposes I don't care about that either.

So in total, I am happy :-) And I find fzf really amazing.