vim + Cscope + YouCompleteMe 实现自动补全与函数查找跳转

一、YouCompleteMe安装 (使用 vim-addon-manager 方式安装,方便简单!!!):
https://blog.csdn.net/sanoseiichirou/article/details/53791317
https://blog.csdn.net/tianminggenie/article/details/82899498
https://blog.csdn.net/lyh__521/article/details/46295775

二、vim+cscope+ctags:
https://blog.csdn.net/qq_26671365/article/details/78871835
https://blog.csdn.net/dengxiayehu/article/details/6330200
https://blog.csdn.net/rikeyone/article/details/82586733
https://blog.csdn.net/weixin_42182073/article/details/80380026
https://blog.csdn.net/laviolette/article/details/51364461

 

#!/bin/bash
DIR=`pwd`
update=1
change=0
while getopts "d:uc" opt;
do
    case $opt in
        d)
            DIR=$OPTARG
			;;
		u)
			update=1
			;;
		c)
			change=1
			;;
		?)
			echo "invaild option!"
			exit 1
	esac
done
 
cd ${DIR}
 
if [ 1 -eq ${change} ]; then
	echo "change project cscope database!"
	res=$(find ${DIR} -name cscope.out)
	if [ "x"${res} = "x" ]; then
		echo "Not found cscope database, generate cscope database!"
        find ${DIR} -name "*.h" -o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.hh" > cscope.files
		cscope -bkq -i cscope.files 
        ctags -R --c++-kinds=+p --fields=+iaS --extra=+q *
		export CSCOPE_DB=${DIR}/cscope.out
	else
		echo "Found cscope database:${res}, just change CSCOPE_DB env!"
		export CSCOPE_DB=${res}
	fi
elif [ 1 -eq ${update} ]; then
	echo "udpate project cscope database!"
    find ${DIR} -name "*.h" -o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.hh" > cscope.files
	cscope -bkq -i cscope.files
    ctags -R --c++-kinds=+p --fields=+iaS --extra=+q *
	export CSCOPE_DB=${DIR}/cscope.out
fi
 
echo CSCOPE_DB_PATH=${CSCOPE_DB}

 

你可能感兴趣的:(vim)