haolongzhangm / auto_update_cscope_ctags_database

auto_update_cscope_ctags_database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Brief (Va.0)

#auto load cscope database and ctags databse, even diffrect project swicth

#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_first_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 :
:Manualstartstopautoupdatedatabas
to start or stop auto update database manually

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

we also add a command :Manualremovedatabase
which will be used for remove database

#easy create new cscope and ctags databse by command :Createtag

can intelligent identificate Linux 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 Linux kernel tree, then call make cscope [ARCH] for gen
kernel database

suppor Linux kernel 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.More info: man find 
Now we support Linux and MAC OS, do not support Windows, caused by windows do not support 'find'
command, If u want to use it at windows env, U need to expand Windows sopport unix-like 'find'
by tools like: 'git for windows'
for cscope we support two backend, cscope and gloabl, default use global
global support incremental update mode,cscope do not support
global will be more fast than cscope, about 2X fast
global will be more accurate than cscope
all ctags file use the same with cscope backend create

Install

#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
4: remove any vim plugn about gnu-global
5: remove any config for gnu-global, like set cscopeprg=gtags-cscope
6: remove autoload_cscope.vim if u have install this script
ps: 1 2 3 4 5function already be integrated in "auto_update_cscope_ctags_database"
7: cp auto_update_cscope_ctags_database/misc_config/.globalrc ~/

#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 :
:PluginInstall

Env check

need must install: cscope 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_first_load_vim)will be disable
which will can use base function(update cscope and ctags database)

(ubuntu/Linux) build


a: sudo apt-get install libgtk2.0-dev libxt-dev libx11-dev
b: sudo apt-get install tcl-dev libperl-dev libncurses5-dev python-dev python3-dev ruby-dev
c: sudo pip install psutil
d: sudo pip3 install psutil
e: install gnu-global from: https://www.gnu.org/software/global/download.html
./configure; make -j2; sudo make install
then merge .globalrc file, if you do not config this file
just do: cp ~/.vim/bundle/auto_update_cscope_ctags_database/misc_config/.globalrc ~/
f: install ctags from: https://github.com/universal-ctags/ctags
sudo apt install gcc make pkg-config autoconf automake python3-docutils
libseccomp-dev libjansson-dev libyaml-dev libxml2-dev
or read docs/autotools.rst of universal-ctags code
./autogen.sh && ./configure && make -j4; sudo make install
g: git clone https://github.com/vim/vim.git download vim src

summary config with python2:
./configure -with-features=huge --enable-rubyinterp --enable-perlinterp=yes --enable-tclinterp=yes
--enable-pythoninterp=yes --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ (this dir may diff between diff pc) 
build/install vim : sudo make install -j8

summary config with python3:
./configure -with-features=huge --enable-rubyinterp --enable-perlinterp=yes --enable-tclinterp=yes -enable-python3interp=yes --with-python-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/ (this dir may diff between diff pc)
build/install vim : sudo make install -j8

#(MacOS) build

0: install brew command: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
a: brew install python
b: brew install python3
c: pip install psutil
d: pip3 install psutil
e: brew install findutils (export PATH=/usr/local/opt/findutils/libexec/gnubin:$PATH); brew install cscope f: install ctags from: https://github.com/universal-ctags/ctags
sudo apt install gcc make pkg-config autoconf automake python3-docutils
libseccomp-dev libjansson-dev libyaml-dev libxml2-dev
or read docs/autotools.rst of universal-ctags code
./autogen.sh && ./configure && make -j4; sudo make install
then close the terminal, reopen a new terminal, then input
'which ctags', which should output the dir '/usr/local/bin/ctags'
not '/usr/bin/ctags'
g: git clone https://github.com/vim/vim.git download vim src
h: ./configure -with-features=huge --enable-rubyinterp --enable-perlinterp=yes --enable-tclinterp=yes --enable-python3interp=yes --enable-cscope --enable-rubyinterp=yes --enable-perlinterp=yes
i: make -j4
j:sudo make install
k: install gnu-global from: https://www.gnu.org/software/global/download.html
./configure; make -j2; sudo make install
then merge .globalrc file, if you do not config this file
just do: cp ~/.vim/bundle/auto_update_cscope_ctags_database/misc_config/.globalrc ~/

config you own prefer Featrue(Do not config anything, plugn also work fine)

g:Auto_update_cscope_ctags_debug_log

default value 0

g:Auto_update_cscope_ctags_timer_filter

For filter Time:
default value 10
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

g:Auto_update_cscope_ctags_lock_floor_max

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

g:auto_update_cscope_ctags_backup_run_py_dir_cache

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"

g:auto_run_function_when_cscope_connect

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

g:check_update_when_first_load_vim

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

g:update_cscope_ctags_do_not_care_dir

default ''
use to config global do not care dir, split with space
for example: let g:update_cscope_ctags_do_not_care_dir = 'build_dir bazel-bin'

issue report

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

About

auto_update_cscope_ctags_database

License:GNU General Public License v2.0


Languages

Language:Vim Script 54.6%Language:Python 32.2%Language:Shell 13.1%