Use this page to discuss script 157 autoload_cscope: search for and load cscope.out databases automatically
- Add constructive comments, bug reports, or discuss improvements (see the guideline).
- Do not document the script here (the author should do that on vim.org).
- This page may be out of date: check the script's vim.org page above, and its release notes.
Comments[]
Usage under MS Windows[]
I changed the windowdir function to:
" windowdir
" Gets the directory for the file in the current window
" Or the current working dir if there isn't one for the window.
" Use tr to allow that other OS paths, too
function s:windowdir()
if winbufnr(0) == -1
let unislash = getcwd()
else
let unislash = fnamemodify(bufname(winbufnr(0)), ':p:h')
endif
return tr(unislash, '\', '/')
endfunc
Dotan, January 27, 2011
Auto Update Database[]
" If you set this to 1, it will auto update your cscope/gtags database and
" reset the cscope connection when you save a file.
if !exists("g:autocscope_auto_update")
let g:autocscope_auto_update = 1
endif
function s:Update_csdb()
if g:autocscope_auto_update != 1
return
endif
if exists("b:csdbpath")
if cscope_connection(3, g:autocscope_tagfile_name, b:csdbpath)
if g:autocscope_use_gtags == 1
"exe "silent !cd " . b:csdbpath . " && global -u &"
exe "silent !cd " . b:csdbpath . " && global -u"
else
"exe "silent !cd " . b:csdbpath . " && cscope -Rbq &"
exe "silent !cd " . b:csdbpath . " && cscope -Rbq"
endif
set nocsverb
exe "cs reset"
set csverb
endif
endif
endfunc
" auto toggle the menu
augroup autoload_cscope
au!
au BufEnter *.[chly] call <SID>Cycle_csdb() | call <SID>Cycle_macros_menus()
au BufEnter *.cc call <SID>Cycle_csdb() | call <SID>Cycle_macros_menus()
au BufWritePost *.[chly] call <SID>Update_csdb() | call <SID>Cycle_macros_menus()
au BufWritePost *.cc call <SID>Update_csdb() | call <SID>Cycle_macros_menus()
au BufUnload *.[chly] call <SID>Unload_csdb() | call <SID>Cycle_macros_menus()
au BufUnload *.cc call <SID>Unload_csdb() | call <SID>Cycle_macros_menus()
augroup END
Flynn December 10, 2011
Support for GNU GLOBAL[]
" If you set this to 1, it will use gtags-cscope instead of cscope which is
" faster than cscope.
if !exists("g:autocscope_use_gtags")
let g:autocscope_use_gtags = 1
endif
if g:autocscope_use_gtags == 1
let g:autocscope_tagfile_name = "GTAGS"
set cscopeprg=gtags-cscope
else
let g:autocscope_tagfile_name = "cscope.out"
set cscopeprg=cscope
endif
In function Cycle_csdb: When use gtags-cscope, should change to the directory that contains the dbs first.
Change:
exe "cs add " . b:csdbpath . "/cscope.out " . b:csdbpath
to:
exe "cd " . b:csdbpath
exe "cs add " . b:csdbpath . "/" . g:autocscope_tagfile_name . " " . b:csdbpath
Then replace "out", "cscope.out" with g:autocscope_tagfile_name at other places. --Flynn December 10, 2011