Merge pull request #87 from AdnoC/master

fzf#vim#buffer_tags([tag commands], options)
This commit is contained in:
Junegunn Choi 2016-02-20 03:01:29 +09:00
commit df25989b2b

View file

@ -432,14 +432,12 @@ endfunction
" ------------------------------------------------------------------
" BTags
" ------------------------------------------------------------------
function! s:btags_source()
function! s:btags_source(tag_cmds)
if !filereadable(expand('%'))
throw 'Save the file first'
endif
for cmd in [
\ printf('ctags -f - --sort=no --excmd=number --language-force=%s %s', &filetype, expand('%:S')),
\ printf('ctags -f - --sort=no --excmd=number %s', expand('%:S'))]
for cmd in a:tag_cmds
let lines = split(system(cmd), "\n")
if !v:shell_error
break
@ -476,12 +474,17 @@ function! s:btags_sink(lines)
normal! zz
endfunction
" [tag commands], options
function! fzf#vim#buffer_tags(...)
let args = copy(a:000)
let tag_cmds = len(args) > 1 ? remove(args, 0) : [
\ printf('ctags -f - --sort=no --excmd=number --language-force=%s %s', &filetype, expand('%:S')),
\ printf('ctags -f - --sort=no --excmd=number %s', expand('%:S'))]
try
return s:fzf(fzf#vim#wrap({
\ 'source': s:btags_source(),
\ 'source': s:btags_source(tag_cmds),
\ 'sink*': s:function('s:btags_sink'),
\ 'options': '--reverse -m -d "\t" --with-nth 1,4.. -n 1 --prompt "BTags> "'}), a:000)
\ 'options': '--reverse -m -d "\t" --with-nth 1,4.. -n 1 --prompt "BTags> "'}), args)
catch
return s:warn(v:exception)
endtry