Skip to content

Commit

Permalink
Get tag files with Vim's tagfiles()
Browse files Browse the repository at this point in the history
Continue #27.
  • Loading branch information
kien committed Nov 28, 2011
1 parent c3b316a commit a4b8d4c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions autoload/ctrlp/tag.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,33 @@ let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:tag_var) : [s:tag_var]

let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)

fu! s:tagfiles()
retu filter(map(tagfiles(), 'fnamemodify(v:val, '':p'')'), 'filereadable(v:val)')
endf
"}}}
" Public {{{
fu! ctrlp#tag#init()
if exists('s:cwd') && s:cwd == getcwd()
let &l:tags = join(sort(s:tagfiles()), ',')
if empty(&l:tags) | retu [] | en
if exists('s:ltags') && s:ltags == &l:tags
let newtags = 0
el
let s:cwd = getcwd()
let s:ltags = &l:tags
let newtags = 1
en
if ( newtags && !exists('g:ctrlp_alltags['''.s:cwd.''']') ) || g:ctrlp_newtag
let alltags = map(taglist('.*'), 'v:val["name"]." ".v:val["filename"]')
cal extend(g:ctrlp_alltags, { s:cwd : alltags })
let s:cwd = getcwd()
if ( newtags && !exists('g:ctrlp_alltags['''.s:ltags.''']') )
\ || g:ctrlp_newtag
let tags = taglist('^.*$')
let alltags = empty(tags) ? []
\ : map(tags, 'v:val["name"]." ".v:val["filename"]')
cal extend(g:ctrlp_alltags, { s:ltags : alltags })
let g:ctrlp_newtag = 0
en
sy match CtrlPTagFilename '\zs\t.*\ze$'
hi link CtrlPTagFilename Comment
retu g:ctrlp_alltags[s:cwd]
retu g:ctrlp_alltags[s:ltags]
endf

fu! ctrlp#tag#accept(mode, str)
Expand Down

0 comments on commit a4b8d4c

Please sign in to comment.