cscope数据库的自动搜索

cscope在vim中不能向ctags一样自动的向上递归的查找索引数据库,一般的解法是手动的添加目录寻找,但是那样既丑陋,又费事情,所以我就把那个重新写了一下


    " add any cscope database in current directory
    if filereadable("cscope.out")
        cs add cscope.out  
    " else add the database pointed to by environment variable 
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
    " find cscope.out or cscope/cscope.out
    else
        let cscope_file = findfile("cscope.out", ";/home/lelouch")
        if !empty(cscope_file) && filereadable(cscope_file)
            exe "cs add " . cscope_file
        else
            let cscope_file = findfile("cscope/cscope.out", ";/home/lelouch")
            if !empty(cscope_file) && filereadable(cscope_file)
                exe "cs add " . cscope_file
            endif
        endif
   endif

这只是cscope_maps.vim中的一小部分,我就改了这一部分.增添的内容主要是查找cscope.out或者在cscope目录下的cscope.out(我喜欢后者,比较干净)


再附上生成数据库的脚本,写的很简陋(都是生成在项目的cscope目录下的.)

生成cscope索引的文件(cscope.files)

#!/bin/bash

cd $1

PROJ_PATH=`pwd`

if [ ! -x "cscope" ]; then
    mkdir cscope
fi

find $PROJ_PATH -name "*.[chsS]" -o -name "*.cpp" > cscope/cscope.files

生成cscope数据库

#!/bin/bash

cd $1/cscope

cscope -bqk -i cscope.files

生成cscope数据库的时候,cscope不会从头生成的,只会生成那些变动过的文件,所以我们平时只需生成数据库即可了


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值