fzf.vim icon indicating copy to clipboard operation
fzf.vim copied to clipboard

:Lines seems broken in Neovim 0.5

Open prizekl opened this issue 3 years ago • 4 comments

  • [x] I have fzf 0.23.0 or above
  • [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
  • [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
  • [x] I have read through the manual page of fzf (man fzf)
  • [x] I have searched through the existing issues

Hi, I really love fzf. Usually I only use Rg and Files. However, recently, Ive been trying to explore more functionalities such as :Lines. However, :Lines isnt behaving. Specifically, a column of '1's on the left and the 'bat error' message: Here is a screenshot of :Lines: Screen Shot 2021-07-07 at 3 47 24 AM Here is a screenshot of :Files which works fine: Screen Shot 2021-07-07 at 3 47 46 AM I am using updated versions of tmux, alacritty, bat, ripgrep, neovim on macOS My configs are:

//init.vim
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden'
let g:fzf_preview_window = ['up:50%', 'ctrl-o']
command! -bang -nargs=* Rg call fzf#vim#grep('rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1, fzf#vim#with_preview({'options': '--delimiter : --nth 2..'}), <bang>0)

//.zshrc
export FZF_DEFAULT_OPTS=" --preview-window=up,50% --preview 'bat --color=always --style=header,grid --line-range :300 {}'"
export BAT_THEME="Visual Studio Dark+"

I apologize if I missed something obvious, I am quite new to coding. Thank you in advance and thank you for the amazing plugin.

prizekl avatar Jul 06 '21 20:07 prizekl

AFAIK, preview doesn't work with :Lines and :BLines, you can check it here: https://github.com/junegunn/fzf.vim/issues/374#issuecomment-301983281.

There's a work around for :BLines to have preview (also in the above url) but not :Lines.

bruhtus avatar Aug 30 '21 08:08 bruhtus

You're not supposed to put --preview option in your $FZF_DEFAULT_OPTS.

https://github.com/junegunn/fzf#preview-window

Since fzf is a general-purpose text filter rather than a file finder, it is not a good idea to add --preview option to your $FZF_DEFAULT_OPTS.

By putting --preview 'bat --color=always --style=header,grid --line-range :300 {}' in your FZF_DEFAULT_OPTS, you're telling fzf to run bat process even when the input lines are not file paths.

seq 100 | fzf --preview 'bat --color=always --style=header,grid --line-range :300 {}'

junegunn avatar Aug 31 '21 05:08 junegunn

You're not supposed to put --preview option in your $FZF_DEFAULT_OPTS.

I could make the error in this particular case go away by adding --no-preview here.

https://github.com/junegunn/fzf.vim/blob/b1afeca8cc02030f450bf1feee015d40988f86e3/autoload/fzf/vim.vim#L471

But then, to be consistent, I'll have to add --no-preview to other commands as well that are not compatible with your --preview option such as :Colors, :Maps, etc.

junegunn avatar Aug 31 '21 05:08 junegunn