summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-03-10 12:13:11 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-03-10 12:13:11 +0900
commit49c752b1f70a72000662f798bcff7ccf23b96e02 (patch)
tree919f2cad400753263e182451c52b08d0ff7d6e63
parentdaa79a6df2282e7d0b45e648dcca3ed077a58828 (diff)
[vim] up/down/left/right options to take boolean values0.9.4-1
When 1 is given, 50% of the screen width or height will be used as the default size of the pane.
-rw-r--r--plugin/fzf.vim20
1 files changed, 13 insertions, 7 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index a3b6abdc..076ab919 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -130,11 +130,20 @@ function! fzf#run(...) abort
endif
endfunction
+function! s:present(dict, ...)
+ for key in a:000
+ if !empty(get(a:dict, key, ''))
+ return 1
+ endif
+ endfor
+ return 0
+endfunction
+
function! s:fzf_tmux(dict)
let size = ''
for o in ['up', 'down', 'left', 'right']
- if has_key(a:dict, o)
- let size = '-'.o[0].a:dict[o]
+ if s:present(a:dict, o)
+ let size = '-'.o[0].(a:dict[o] == 1 ? '' : a:dict[o])
endif
endfor
return printf('LINES=%d COLUMNS=%d %s %s %s --',
@@ -142,14 +151,11 @@ function! s:fzf_tmux(dict)
endfunction
function! s:tmux_splittable(dict)
- return has_key(a:dict, 'up') ||
- \ has_key(a:dict, 'down') ||
- \ has_key(a:dict, 'left') ||
- \ has_key(a:dict, 'right')
+ return s:present(a:dict, 'up', 'down', 'left', 'right')
endfunction
function! s:pushd(dict)
- if !empty(get(a:dict, 'dir', ''))
+ if s:present(a:dict, 'dir')
let a:dict.prev_dir = getcwd()
execute 'chdir '.s:escape(a:dict.dir)
return 1