mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-18 02:05:57 +08:00
fzf#vim#buffer_tags([tag commands], options)
Added ability to specify the commands used to generate tags
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user