mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-01 12:42:01 -07:00
[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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user