[vim] make autotags look for tag/cscope in parent dir until HOME or /
This commit is contained in:
parent
71a9364222
commit
50461a952f
@ -217,7 +217,7 @@ fun! s:AutotagsInit()
|
||||
while l:dir != "/"
|
||||
if getftype(g:autotagsdir . '/' . s:PathHash(l:dir)) == "dir"
|
||||
let s:autotags_subdir = g:autotagsdir . '/' . s:PathHash(l:dir)
|
||||
"echomsg "autotags subdir exist: " . s:autotags_subdir
|
||||
echomsg "autotags subdir exist: " . s:autotags_subdir
|
||||
break
|
||||
endif
|
||||
" get parent directory
|
||||
@ -239,20 +239,48 @@ fun! s:AutotagsIsC()
|
||||
endif
|
||||
endfun
|
||||
|
||||
fun! GetLocalCscopeDb(pathname)
|
||||
if !isdirectory(a:pathname) || a:pathname == $HOME || a:pathname == '/'
|
||||
return
|
||||
endif
|
||||
let s:cscopefile = a:pathname."/cscope.out"
|
||||
if filereadable(s:cscopefile)
|
||||
" echo "Add cscope db for ".a:pathname
|
||||
execute "cscope add ".s:cscopefile." ".a:pathname
|
||||
endif
|
||||
unlet s:cscopefile
|
||||
call GetLocalCscopeDb(fnamemodify(a:pathname, ":h"))
|
||||
endfunction
|
||||
|
||||
fun! GetLocalTags(pathname)
|
||||
if !isdirectory(a:pathname) || a:pathname == $HOME || a:pathname == '/'
|
||||
return
|
||||
endif
|
||||
let s:ctagsfile = a:pathname."/tags"
|
||||
if filereadable(s:ctagsfile)
|
||||
" echo "Add tags db for ".a:pathname
|
||||
exe "set tags+=" . s:ctagsfile
|
||||
endif
|
||||
unlet s:ctagsfile
|
||||
call GetLocalTags(fnamemodify(a:pathname, ":h"))
|
||||
endfunction
|
||||
|
||||
fun! s:AutotagsSearchLoadTags()
|
||||
" search ctags in current tree
|
||||
if filereadable(findfile("tags", ".;"))
|
||||
let l:ctagsfile = findfile("tags", ".;")
|
||||
exe "set tags+=" . l:ctagsfile
|
||||
echomsg "found local ctags file: " . l:ctagsfile
|
||||
endif
|
||||
call GetLocalTags(expand("%:p:h"))
|
||||
" if filereadable(findfile("tags", ".;"))
|
||||
" let l:ctagsfile = findfile("tags", ".;")
|
||||
" exe "set tags+=" . l:ctagsfile
|
||||
" echomsg "found local ctags file: " . l:ctagsfile
|
||||
" endif
|
||||
|
||||
call GetLocalCscopeDb(expand("%:p:h"))
|
||||
" search cscope db in current tree
|
||||
if filereadable(findfile("cscope.out", ".;"))
|
||||
let l:cscopedb = findfile("cscope.out", ".;")
|
||||
exe "cs add " . l:cscopedb . " " . fnamemodify(l:cscopedb, ":p:h")
|
||||
echomsg "found local cscopedb file: " . l:cscopedb
|
||||
endif
|
||||
" if filereadable(findfile("cscope.out", ".;"))
|
||||
" let l:cscopedb = findfile("cscope.out", ".;")
|
||||
" exe "cs add " . l:cscopedb . " " . fnamemodify(l:cscopedb, ":p:h")
|
||||
" echomsg "found local cscopedb file: " . l:cscopedb
|
||||
" endif
|
||||
endfun
|
||||
|
||||
" remove stale tags for non-existing source directories
|
||||
|
@ -103,6 +103,9 @@ if has("cscope")
|
||||
endfunction
|
||||
command! GenerateCscopeDb :call GenerateCscopeDb()
|
||||
|
||||
" Let autotags find all cscodepeDb
|
||||
" LoadLocalCscopeDb
|
||||
|
||||
"" if has("cscope")
|
||||
"" map <F9> :call GetCscopeDb(expand("%:p:h")) <CR><CR>
|
||||
"" map <S-F9> :call GenerateCscopeDb() <CR><CR>
|
||||
|
Loading…
Reference in New Issue
Block a user