Skip to content
Myr

[vim] Change the default layout to use popup window

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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)

authored by Junegunn Choi · committed by Junegunn Choi · parent e0f0b5b · Browse files · 3 files+21 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+21 added−9 removed

  • other:+21 added−9 removed

3 files+21 added−9 removed

modified:doc/fzf.txt+5 added-3 removed
152 unmodified lines
153 \ 'ctrl-x': 'split',154 \ 'ctrl-v': 'vsplit' }155156 " Default fzf layout157 " - down / up / left / right157 " - down / up / left / right / window158 let g:fzf_layout = { 'down': '~40%' }159 let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }160161 " You can set up fzf window using a Vim command (Neovim or latest Vim 8 required)162 let g:fzf_layout = { 'window': 'enew' }163 let g:fzf_layout = { 'window': '-tabnew' }
262 unmodified lines
426When fzf starts in a terminal buffer, the file type of the buffer is set to427`fzf`. So you can set up `FileType fzf` autocmd to customize the settings of428the window.429429For example, if you use the default layout (`{'down': '~40%'}`) on Neovim, you430might want to temporarily disable the statusline for a cleaner look.430For example, if you use a non-popup layout (e.g. `{'down': '40%'}`) on431Neovim, you might want to temporarily disable the statusline for a cleaner432look.433>434 if has('nvim') && !exists('g:fzf_layout')435 autocmd! FileType fzf436 autocmd FileType fzf set laststatus=0 noshowmode noruler
13 unmodified lines
modified:plugin/fzf.vim+12 added-3 removed
113 unmodified lines
114function! s:fzf_tempname()115 return s:fzf_call('tempname')116endfunction117118let s:default_layout = { 'down': '~40%' }118let s:layout_keys = ['window', 'tmux', 'up', 'down', 'left', 'right']119let s:fzf_go = s:base_dir.'/bin/fzf'120let s:fzf_tmux = s:base_dir.'/bin/fzf-tmux'121122let s:cpo_save = &cpo123set cpo&vim124125function! s:popup_support()126 return has('nvim') ? has('nvim-0.4') : has('popupwin') && has('patch-8.2.191')127endfunction128129function! s:default_layout()130 return s:popup_support()131 \ ? { 'window' : { 'width': 0.9, 'height': 0.6, 'highlight': 'Normal' } }132 \ : { 'down': '~40%' }133endfunction134135function! fzf#install()136 if s:is_win && !has('win32unix')137 let script = s:base_dir.'/install.ps1'138 if !filereadable(script)
194 unmodified lines
333 elseif !s:has_any(opts, s:layout_keys)334 if !exists('g:fzf_layout') && exists('g:fzf_height')335 let opts.down = g:fzf_height336 else328 let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout)))337 let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout())))338 endif339 endif340341 " Colors: g:fzf_colors
324 unmodified lines
666 let is_popup = 0667 try668 if s:present(a:dict, 'window')669 if type(a:dict.window) == type({})661 if !(has('nvim') ? has('nvim-0.4') : has('popupwin') && has('patch-8.2.191'))670 if !s:popup_support()671 throw 'Nvim 0.4+ or Vim 8.2.191+ with popupwin feature is required for pop-up window'672 end673 call s:popup(a:dict.window)674 let is_popup = 1
290 unmodified lines
modified:README-VIM.md+4 added-3 removed
125 unmodified lines
126 \ 'ctrl-x': 'split',127 \ 'ctrl-v': 'vsplit' }128129" Default fzf layout130" - down / up / left / right130" - down / up / left / right / window131let g:fzf_layout = { 'down': '40%' }132let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }133134" You can set up fzf window using a Vim command (Neovim or latest Vim 8 required)135let g:fzf_layout = { 'window': 'enew' }136let g:fzf_layout = { 'window': '-tabnew' }
279 unmodified lines
416When fzf starts in a terminal buffer, the file type of the buffer is set to417`fzf`. So you can set up `FileType fzf` autocmd to customize the settings of418the window.419419For example, if you use the default layout (`{'down': '40%'}`) on Neovim, you420might want to temporarily disable the statusline for a cleaner look.420For example, if you use a non-popup layout (e.g. `{'down': '40%'}`) on Neovim,421you might want to temporarily disable the statusline for a cleaner look.422423```vim424if has('nvim') && !exists('g:fzf_layout')425 autocmd! FileType fzf
11 unmodified lines