[vim] Change the default layout to use popup window

The new default is

  { 'window' : { 'width': 0.9, 'height': 0.6, 'highlight': 'Normal' } }

The default highlight group for the border of the popup window is
'Comment', but 'Normal' seems to be a safer choice.

If you prefer the previous default, add this to your Vim configuration file:

  let g:fzf_layout = { 'down': '40%' }

(fzf will fall back to this if popup window is not supported)
This commit is contained in:
Junegunn Choi 2020-09-12 21:08:05 +09:00
parent e0f0b5bcf9
commit c60ed17583
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
3 changed files with 21 additions and 9 deletions

View File

@ -127,8 +127,9 @@ let g:fzf_action = {
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
" - down / up / left / right / window
let g:fzf_layout = { 'down': '40%' }
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
" You can set up fzf window using a Vim command (Neovim or latest Vim 8 required)
let g:fzf_layout = { 'window': 'enew' }
@ -416,8 +417,8 @@ When fzf starts in a terminal buffer, the file type of the buffer is set to
`fzf`. So you can set up `FileType fzf` autocmd to customize the settings of
the window.
For example, if you use the default layout (`{'down': '40%'}`) on Neovim, you
might want to temporarily disable the statusline for a cleaner look.
For example, if you use a non-popup layout (e.g. `{'down': '40%'}`) on Neovim,
you might want to temporarily disable the statusline for a cleaner look.
```vim
if has('nvim') && !exists('g:fzf_layout')

View File

@ -154,8 +154,9 @@ Examples~
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
" - down / up / left / right / window
let g:fzf_layout = { 'down': '~40%' }
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
" You can set up fzf window using a Vim command (Neovim or latest Vim 8 required)
let g:fzf_layout = { 'window': 'enew' }
@ -426,8 +427,9 @@ When fzf starts in a terminal buffer, the file type of the buffer is set to
`fzf`. So you can set up `FileTypefzf` autocmd to customize the settings of
the window.
For example, if you use the default layout (`{'down':'~40%'}`) on Neovim, you
might want to temporarily disable the statusline for a cleaner look.
For example, if you use a non-popup layout (e.g. `{'down':'40%'}`) on
Neovim, you might want to temporarily disable the statusline for a cleaner
look.
>
if has('nvim') && !exists('g:fzf_layout')
autocmd! FileType fzf

View File

@ -115,7 +115,6 @@ function! s:fzf_tempname()
return s:fzf_call('tempname')
endfunction
let s:default_layout = { 'down': '~40%' }
let s:layout_keys = ['window', 'tmux', 'up', 'down', 'left', 'right']
let s:fzf_go = s:base_dir.'/bin/fzf'
let s:fzf_tmux = s:base_dir.'/bin/fzf-tmux'
@ -123,6 +122,16 @@ let s:fzf_tmux = s:base_dir.'/bin/fzf-tmux'
let s:cpo_save = &cpo
set cpo&vim
function! s:popup_support()
return has('nvim') ? has('nvim-0.4') : has('popupwin') && has('patch-8.2.191')
endfunction
function! s:default_layout()
return s:popup_support()
\ ? { 'window' : { 'width': 0.9, 'height': 0.6, 'highlight': 'Normal' } }
\ : { 'down': '~40%' }
endfunction
function! fzf#install()
if s:is_win && !has('win32unix')
let script = s:base_dir.'/install.ps1'
@ -325,7 +334,7 @@ function! fzf#wrap(...)
if !exists('g:fzf_layout') && exists('g:fzf_height')
let opts.down = g:fzf_height
else
let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout)))
let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout())))
endif
endif
@ -658,7 +667,7 @@ function! s:split(dict)
try
if s:present(a:dict, 'window')
if type(a:dict.window) == type({})
if !(has('nvim') ? has('nvim-0.4') : has('popupwin') && has('patch-8.2.191'))
if !s:popup_support()
throw 'Nvim 0.4+ or Vim 8.2.191+ with popupwin feature is required for pop-up window'
end
call s:popup(a:dict.window)