sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

auto_update_cscope_ctags_database : 1:auto update cscope ctags database2:easy create database 3: auto plugn database

 script karma  Rating 0/0, Downloaded by 148    Comments, bugs, improvements  Vim wiki

created by
Hidin zhang
script type
Brief (V2.0)
#auto load cscope database and ctags databse, even diffrect project swicth(base third part)

#auto update database if cscope connect
After run buffer write command eg, w, we will try update database if already connect a cscope database,
also we can check file update(may casued by git pull , add new file or edit by notepad)
when fistly load vim
if U do not want vim check database update when firstly load vim  
add below in ~/.vimrc
let g:check_update_when_fisrt_load_vim = 0

if U do not want to auto update database during edit you file
add below in ~/.vimrc
let g:auto_run_function_when_cscope_connect = 0
then you can run command :
to start or stop auto update database

we also add a command :Manualupdatedatabaseonetime
which porvide a chance to update database onetime
espiaclly, user disable g:auto_run_function_when_cscope_connect = 0

#easy create new cscope and ctags databse by command  :Createtag
can intelligent identificate kernel dir eg:
even U eidt at subdir like  vim kirkwood-cpufreq.c  at dir kernel/drivers/cpufreq
we can intelligent detect it is a kernel tree, then call make cscope [ARCH] for gen
kernel database

suppor ARCH:
alpha', 'arm', 'avr32', 'c6x', 'frv', 'hexagon', 'm68k', 'microblaze', 'mn10300',
parisc', 's390', 'sh', 'tile', 'unicore32', 'xtensa', 'arc', 'arm64', 'blackfin',
cris', 'h8300', 'ia64', 'm32r', 'metag', 'mips', 'openrisc', 'powerpc', 'score',
sparc', 'um', 'x86
if we can not  match kernel tree we will use  find command to gen needed files  


#Install before todo
U need remove old config like:
1: remove hard config database in vimrc eg: set tag=tags;
2: remove hard config database in vimrc eg: cs add xxx
3: also need remove database manage plugn if U used
ps: 1 2 3 function already be integrated in "auto_update_cscope_ctags_database"

#ways A
git clone git@github.com:haolongzhangm/auto_update_cscope_ctags_database.git
then put plugn file to ~/.vim/plugn

#ways B
if u use bundle
just add
'Bundle 'haolongzhangm/auto_update_cscope_ctags_database'
in ~/.vimrc
then run :

remove autoload_cscope.vim if u have install this script(we add more interface in autoload_cscope_ctags.vim,
which base on autoload_cscope.vim )

Env check
need must install: cscope ctags sed python and vim_with_python( vim --version| grep python)

if you os support command: gnome-osd-client or notify-send , GUI will show mesage when collect database

also suggest build vim with timers(vim --version| grep timers)

if U vim do not support timers , Feature (auto reset cscope' and 'check_update_when_fisrt_load_vim)will be disable
which will can use base function(update cscope and ctags database)

#build new vim for support timers and python
0: before build vim,suggest install: (ubuntu)sudo apt-get install libgtk2.0-dev libxt-dev libx11-dev
tcl-dev libperl-dev libncurses5-dev python-dev python3-dev(if U use python3)
a:  https://github.com/vim/vim download vim src
b: ./configure  -with-features=huge --enable-rubyinterp --enable-perlinterp=yes --enable-tclinterp=yes

for python please choose python2 or python3  

--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/  (this dir may diff between diff pc) 

--with-python-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/ (this dir may diff between diff pc)

suggest  build with python2
c:make -j2
d:sudo make install
e:open a new terminal input command: vim --version to check vim support feature

config you own prefer Featrue(if Do not config anything, plugn also work fine)
default value 0

For filter Time:
default value 60
this time for filter modify frequency"
if you want to see database update immediately
you can modify to 10s or 1s, which I do not suggest
,caused by csocpe or ctags gen database may take a
big occupy on disk,you can override at .vimrc

default value 1800
this time for wait cscope or ctag gen tags finish
or vim closed when gen ctags run last time,
on SSD , gen cscope database(kernel code) may take 20s
on HDD/7200 gen cscope database(kernel code)may take 50s
so, I suggest keep, this vale to 1800(30min), if you PC
I/O is so slow more than 30min, you may chang this value
you can override at .vimrc

default  '~/.vim/bundle/auto_update_cscope_ctags_database/plugin/auto_update_cscope_ctags_backup_run.py'

you may set this in you .vimrc
for plugn run quickly, but even
you config err, we can also find it"

default 1
:when find cscope connect/first load
or buffers swith
if you set to 0 in vimrc,
you need use command:
to start or stop auto update database

default 1
when 1, we will try to check database need update or not
eg: you add some file in project or edit src by git pull or
other editer like gedit or notepad, we can detect the update
you can disable this Feature in .vimrc

issue report
*1:enable  'let g:Auto_update_cscope_ctags_debug_log = 1' in ~/.vimrc
*2:reopen vim , reproducte issue
*3:upload logfile : /tmp/.Auto_update_cscope_ctags_debug_back_run.log /tmp/.Auto_update_cscope_ctags_debug_log.log
*4:also upload err info in vim eidt window

github link :    https://github.com/haolongzhangm/auto_update_cscope_ctags_database
install details

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
auto_update_cscope_ctags_database.tar.gz v2.0.5 2017-07-21 7.0 Hidin zhang
    compat for find command more versin:some find will
    return err when use like :find -name *.py
    should be find -name '*.c'
    do not call remove cscope database when leave from *.py
    caused by python lib API dir do not include a database
    when into python Lib dir ,we want to use old database
    will cause new 'issue' TODO:
        when in python project, while do not support
        diff project databse swith
auto_update_cscope_ctags_database.tar.gz v2.0.4 2017-07-20 7.0 Hidin zhang add python lib API jump support, (only for normal project , do not support kernel project)
auto_update_cscope_ctags_database.tar.gz v2.0.3 2017-07-19 7.0 Hidin zhang add more file type, support baidu apollo easy tag
auto_update_cscope_ctags_database.tar.gz 2.0.2 2017-05-24 7.0 Hidin zhang update version to 2.0.2

Add cmdline mode detect
            cmdline do not supprot command:eg cs reset
            so we delay "Cscope_reset_detect_timer" func
            when in cmdline mode

            make a difference between kernel mode and 'normal' mode
            when gen ctags args

auto_update_cscope_ctags_database.tar.gz 2.0.1 2017-05-20 7.0 Hidin zhang update version to 2.0.1

Fix issue:
            change g:check_update_when_fisrt_load_vim mode to 3
            let check_update_when_fisrt_load_vim do not depend on

open more feature for ctags, helpfull for c++ and java type

add more fiter for ctags, which is help for kernel code
auto_update_cscope_ctags_database.tar.gz 2.0 2017-05-19 7.0 Hidin zhang     add command Manualupdatedatabaseonetime
            some user may disable g:auto_run_function_when_cscope_connect
            so we add a command to user user have a chance to update
            database onetime
auto_update_cscope_ctags_database.tar.gz 1.0.1 2017-05-12 7.0 Hidin zhang fix v1.0 issue
auto_update_cscope_ctags_database.tar.gz 1.0 2017-05-03 7.0 Hidin zhang Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo