fzf#vim#buffer_tags([tag commands], options)

Added ability to specify the commands used to generate tags
This commit is contained in:
AdnoC
2016-02-18 23:58:59 -05:00
parent be01b64586
commit 2133f25675

View File

@@ -432,14 +432,12 @@ endfunction
" ------------------------------------------------------------------ " ------------------------------------------------------------------
" BTags " BTags
" ------------------------------------------------------------------ " ------------------------------------------------------------------
function! s:btags_source() function! s:btags_source(tag_cmds)
if !filereadable(expand('%')) if !filereadable(expand('%'))
throw 'Save the file first' throw 'Save the file first'
endif endif
for cmd in [ for cmd in a:tag_cmds
\ printf('ctags -f - --sort=no --excmd=number --language-force=%s %s', &filetype, expand('%:S')),
\ printf('ctags -f - --sort=no --excmd=number %s', expand('%:S'))]
let lines = split(system(cmd), "\n") let lines = split(system(cmd), "\n")
if !v:shell_error if !v:shell_error
break break
@@ -476,12 +474,17 @@ function! s:btags_sink(lines)
normal! zz normal! zz
endfunction endfunction
" [tag commands], options
function! fzf#vim#buffer_tags(...) 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 try
return s:fzf(fzf#vim#wrap({ return s:fzf(fzf#vim#wrap({
\ 'source': s:btags_source(), \ 'source': s:btags_source(tag_cmds),
\ 'sink*': s:function('s:btags_sink'), \ '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 catch
return s:warn(v:exception) return s:warn(v:exception)
endtry endtry