summaryrefslogtreecommitdiff
path: root/plugin/fzf.vim
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2013-11-17 02:41:10 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2013-11-17 02:41:10 +0900
commit90adda73b0d779348eecd2e62b075fc542ec21fa (patch)
tree0748450db8b691ca31c0ea48140738fb75e596a2 /plugin/fzf.vim
parentbe3b948034a8201dae1b85b6d6f4885339f87af3 (diff)
downloadfzf-90adda73b0d779348eecd2e62b075fc542ec21fa.tar.gz
Update Vim plugin
Changes: - Rename g:fzf_command to g:fzf_source - Support multi-select mode - Add fzf#run(vim_command, fzf_args) function Todo: - Faster startup with --disable-gems option when available
Diffstat (limited to 'plugin/fzf.vim')
-rw-r--r--plugin/fzf.vim24
1 files changed, 13 insertions, 11 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 70664038..206f571d 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -23,23 +23,25 @@
let s:exec = expand('<sfile>:h:h').'/fzf'
-function! s:fzf(args)
+function! fzf#run(command, args)
try
- let tf = tempname()
- let prefix = exists('g:fzf_command') ? g:fzf_command.'|' : ''
- let fzf = executable(s:exec) ? s:exec : 'fzf'
- execute "silent !".prefix.fzf." ".a:args." > ".tf
+ let tf = tempname()
+ let prefix = exists('g:fzf_source') ? g:fzf_source.'|' : ''
+ let fzf = executable(s:exec) ? s:exec : 'fzf'
+ let options = empty(a:args) ? get(g:, 'fzf_options', '') : a:args
+ execute "silent !".prefix.fzf.' '.options." > ".tf
if !v:shell_error
- let file = join(readfile(tf), '')
- if !empty(file)
- execute 'silent e '.file
- endif
+ for line in readfile(tf)
+ if !empty(line)
+ execute a:command.' '.line
+ endif
+ endfor
endif
finally
- silent! call delete(tf)
redraw!
+ silent! call delete(tf)
endtry
endfunction
-command! -nargs=* FZF call s:fzf(<q-args>)
+command! -nargs=* FZF call fzf#run('silent e', <q-args>)