junegunn / fzf

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

nvim window height for fzf#run is not enough for 2 options #1535

Closed ipwnponies closed 5 years ago

ipwnponies commented 5 years ago

Summary

When calling fzf#run with 2 results, the fzf window is not sufficiently tall to display any results.

Repro

Setup

minimal_vimrc:

set nocompatible
call plug#begin('~/.vim/bundle')
    Plug 'junegunn/fzf', { 'dir': '~/.local/share/fzf', 'do': './install --all' }
call plug#end()

Command:

$ nvim -u minimal_vimrc
:call fzf#run({'source': ['oh hi', 'oh bye'], 'down': '~40%'})

I don't know what 'down' option does, it's provided by default from fzf#wrap. https://github.com/junegunn/fzf/blob/315e568de006e80138f79c77d5508c7e4853e6b2/plugin/fzf.vim#L302-L308 It's how LanguageClient-neovim is using it, for additional context on use case.

Results

minimal_vimrc

Works for vim8 (8.0.1453) image Broken in nvim (v0.3.1) image

Using actual vimrc

I think this may provide clues. It looks like a padding issue, need more to account for neovim terminal mode? vim image neovim image

junegunn commented 5 years ago

Looks like you have --border in your FZF_DEFAULTS_OPTS. That has not been not correctly handled by Vim wrapper, so the problem is also reproducible on Vim if we force it to use a terminal buffer by using layout option other than down.

:let $FZF_DEFAULT_OPTS = ''
:call fzf#run({'source': range(2), 'up': '~40%', 'options': '--no-border --no-inline-info'})
:call fzf#run({'source': range(2), 'up': '~40%', 'options': '--inline-info'})
:call fzf#run({'source': range(2), 'up': '~40%', 'options': '--border'})
:call fzf#run({'source': range(2), 'up': '~40%', 'options': '--inline-info --border --header foo'})

" Not sure why this one doesn't work as expected
:call fzf#run({'source': range(2), 'up': '~40%', 'options': '--inline-info --border'})

Anyway, the above patch (in devel branch, soon to be merged to master) should help.

ipwnponies commented 5 years ago

Oh nice, I forgot to mention the env var:

FZF_DEFAULTS_OPTS = --reverse --select-1 --exit-0 --border --height 40%  --min-height 10 --margin 1,5 --inline-info --bind pgdn:preview-page-down,pgup:preview-page-up,change:top,ctrl-s:toggle-sort

I've tested your repro and and can confirm it only occurs when both --inline-info and --border are set.