summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-09-12 21:08:05 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-09-12 21:14:32 +0900
commitc60ed1758315f0d993fbcbf04459944c87e19a48 (patch)
treeef9183638391630c0157be73a32ee2b64c259239
parente0f0b5bcf9e42d16ca4e1007e6d1b170388b3edc (diff)
downloadfzf-c60ed1758315f0d993fbcbf04459944c87e19a48.tar.gz
[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)
-rw-r--r--README-VIM.md7
-rw-r--r--doc/fzf.txt8
-rw-r--r--plugin/fzf.vim15
3 files changed, 21 insertions, 9 deletions
diff --git a/README-VIM.md b/README-VIM.md
index af514da0..126862b2 100644
--- a/README-VIM.md
+++ b/README-VIM.md
@@ -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')
diff --git a/doc/fzf.txt b/doc/fzf.txt
index e88f7564..2c04872d 100644
--- a/doc/fzf.txt
+++ b/doc/fzf.txt
@@ -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 `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.
>
if has('nvim') && !exists('g:fzf_layout')
autocmd! FileType fzf
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 2e12739e..83e1cef5 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -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)