Make fzf#vim#complete#path take command as the first argument

inoremap <expr> <c-x><c-g> fzf#vim#complete#path('git ls-files $(git rev-parse --show-toplevel)')
This commit is contained in:
Junegunn Choi
2015-09-12 02:52:43 +09:00
parent 2a9ac9602b
commit 47fb2c3eb6
2 changed files with 5 additions and 17 deletions

View File

@@ -102,24 +102,12 @@ function! s:fname_prefix(str)
return prefix
endfunction
function! s:complete_file(command, extra_opts)
function! fzf#vim#complete#path(command, ...)
let s:file_cmd = a:command
return fzf#vim#complete(extend({
\ 'prefix': function('s:fname_prefix'),
\ 'source': function('s:file_source'),
\ 'options': function('s:file_options')}, get(a:extra_opts, 0, g:fzf#vim#default_layout)))
endfunction
function! fzf#vim#complete#path(...)
return s:complete_file("find . -path '*/\.*' -prune -o -print \| sed '1d;s:^..::'", a:000)
endfunction
function! fzf#vim#complete#file(...)
return s:complete_file("find . -path '*/\.*' -prune -o -type f -print -o -type l -print \| sed '1d;s:^..::'", a:000)
endfunction
function! fzf#vim#complete#file_ag(...)
return s:complete_file("ag -l -g ''", a:000)
\ 'options': function('s:file_options')}, get(a:000, 0, g:fzf#vim#default_layout)))
endfunction
" ----------------------------------------------------------------------------

View File

@@ -63,9 +63,9 @@ function! fzf#complete(...)
endfunction
inoremap <expr> <plug>(fzf-complete-word) fzf#vim#complete#word()
inoremap <expr> <plug>(fzf-complete-path) fzf#vim#complete#path()
inoremap <expr> <plug>(fzf-complete-file) fzf#vim#complete#file()
inoremap <expr> <plug>(fzf-complete-file-ag) fzf#vim#complete#file_ag()
inoremap <expr> <plug>(fzf-complete-path) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -print \| sed '1d;s:^..::'")
inoremap <expr> <plug>(fzf-complete-file) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -type f -print -o -type l -print \| sed '1d;s:^..::'")
inoremap <expr> <plug>(fzf-complete-file-ag) fzf#vim#complete#path("ag -l -g ''")
inoremap <expr> <plug>(fzf-complete-line) fzf#vim#complete#line()
inoremap <expr> <plug>(fzf-complete-buffer-line) fzf#vim#complete#buffer_line()