summaryrefslogtreecommitdiff
path: root/plugin/fzf.vim
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-03-02 14:14:57 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-03-02 14:14:57 +0900
commit111d1934c49ac22cf84abf0ada9c24f091fc38cd (patch)
tree358596f145a77af744a5019cd53a8a3184c53c6a /plugin/fzf.vim
parent972fb1a29ddd484c97342cf0e7399bd904ded58d (diff)
downloadfzf-111d1934c49ac22cf84abf0ada9c24f091fc38cd.tar.gz
[vim] Throw error if g:fzf_layout is incorrectly used
https://github.com/junegunn/fzf.vim/issues/327 https://github.com/junegunn/fzf.vim/issues/317
Diffstat (limited to 'plugin/fzf.vim')
-rw-r--r--plugin/fzf.vim12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 932efde1..840d1fed 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -192,6 +192,16 @@ function! s:defaults()
return empty(colors) ? '' : ('--color='.colors)
endfunction
+function! s:validate_layout(layout)
+ for key in keys(a:layout)
+ if index(s:layout_keys, key) < 0
+ throw printf('invalid entry in g:fzf_layout: %s (allowed: %s)%s',
+ \ key, join(s:layout_keys, ', '), key == 'options' ? '. Use $FZF_DEFAULT_OPTS.' : '')
+ endif
+ endfor
+ return a:layout
+endfunction
+
" [name string,] [opts dict,] [fullscreen boolean]
function! fzf#wrap(...)
let args = ['', {}, 0]
@@ -223,7 +233,7 @@ function! fzf#wrap(...)
if !exists('g:fzf_layout') && exists('g:fzf_height')
let opts.down = g:fzf_height
else
- let opts = extend(opts, get(g:, 'fzf_layout', s:default_layout))
+ let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout)))
endif
endif