Pass s:tagfiles to tag.vim

* Pass s:tagfiles and path of the current buffer to tag.vim
  to properly expand '.' in the 'tags' option. Continue #27.
This commit is contained in:
Kien N 2011-11-29 07:12:58 +07:00
parent a4b8d4cd38
commit d6504d2eb5
2 changed files with 12 additions and 9 deletions

View File

@ -67,6 +67,7 @@ fu! s:Open()
let [s:cwd, s:winres] = [getcwd(), winrestcmd()]
let [s:crfile, s:crfpath] = [expand('%:p', 1), expand('%:p:h', 1)]
let [s:crword, s:crvisual] = [expand('<cword>'), s:lastvisual()]
let s:tagfiles = s:tagfiles()
sil! exe s:mwbottom ? 'bo' : 'to' '1new ControlP'
let s:currwin = s:mwbottom ? winnr('#') : winnr('#') + 1
let [s:bufnr, s:prompt] = [bufnr('%'), ['', '', '']]
@ -94,7 +95,7 @@ fu! s:Close()
let [g:ctrlp_lines, g:ctrlp_allfiles] = [[], []]
exe s:winres
unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr
\ s:crfile s:crfpath s:crword s:crvisual g:ctrlp_nolimit
\ s:crfile s:crfpath s:crword s:crvisual s:tagfiles g:ctrlp_nolimit
cal s:recordhist(join(s:prompt, ''))
ec
endf
@ -1243,6 +1244,11 @@ fu! s:lscommand()
en
endf
"}}}
" Extensions {{{
fu! s:tagfiles()
retu filter(map(tagfiles(), 'fnamemodify(v:val, ":p")'), 'filereadable(v:val)')
endf
"}}}
"}}}
" * Initialization {{{
fu! s:SetLines(type)

View File

@ -10,20 +10,17 @@ if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag
en
let [g:loaded_ctrlp_tag, g:ctrlp_newtag] = [1, 0]
let s:tag_var = ['ctrlp#tag#init()', 'ctrlp#tag#accept', 'tags', 'tag']
let s:tag_var = ['ctrlp#tag#init(s:tagfiles, s:crfpath)', 'ctrlp#tag#accept',
\ 'tags', 'tag']
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()
let &l:tags = join(sort(s:tagfiles()), ',')
fu! ctrlp#tag#init(tagfiles, crfpath)
let &l:tags = join(sort(a:tagfiles), ',')
if empty(&l:tags) | retu [] | en
if exists('s:ltags') && s:ltags == &l:tags
let newtags = 0
@ -31,7 +28,7 @@ fu! ctrlp#tag#init()
let s:ltags = &l:tags
let newtags = 1
en
let s:cwd = getcwd()
let s:cwd = a:crfpath
if ( newtags && !exists('g:ctrlp_alltags['''.s:ltags.''']') )
\ || g:ctrlp_newtag
let tags = taglist('^.*$')