为什么 vim 中的 cscope 和 ctags 组合显示与 class 无关的函数定义的结果?
Why combination of cscope and ctags in vim are showing results for a function definition that is not related to a class?
我在 vim 编辑器中为一个 c++ 项目使用 cscope 和 ctags。我已经从项目的根目录生成了如下的 ctags 和 cscope 文件。
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q
find . -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" > cscope.files
cscope -q -R -b -i cscope.files
我的~/.vimrc文件内容如下
set tags+=./tags;/
filetype plugin on
cs add $CSCOPE_DB
我在 .bashrc 中添加了下面一行
export CSCOPE_DB=/home/kadina/build/platform/component/platform/stb/cscope.out
而且我已经从互联网上下载了 cscope_maps.vim 并将其放在 ~/.vim/plugin/
但是当我试图通过 ctrl + } 查找函数的定义时,它列出了所有具有相同名称的函数定义,而不是导航到正确的函数。
例如,当我试图找到 VZ_DIAGNOSTICS::getInstance() 的定义时,它并没有导航到 VZ_DIAGNOSTICS::getInstance() 的定义,而是列出了所有带有命名为 getInstance().
当我试图通过 ctrl + \ + c 查找谁在调用此函数时,我遇到了同样的问题。它列出了调用 getInstance() 的函数,而不是列出调用 VZ_DIAGNOSTICS::getInstance().
的函数
任何人都可以让我知道我需要进行哪些更改才能正常工作吗?
因为它使用cstags而不是ctags。
这是我使用的配置。我不安装 cscope_maps.vim 因为我不需要 cscope 的键盘快捷键。
set nocscopetag
禁用 cstags。其他东西使它在 git 项目中自动加载 cscope.out 而无需环境变量。
set nocscopetag
if filereadable("cscope.out")
cscope add cscope.out
else
let git_path = finddir('.git', '.;')
let cscope_path = git_path . "/../cscope.out"
let proj_dir = git_path . "/../"
if filereadable(cscope_path)
execute "cscope add " . cscope_path . ' ' . proj_dir
endif
endif
我在 vim 编辑器中为一个 c++ 项目使用 cscope 和 ctags。我已经从项目的根目录生成了如下的 ctags 和 cscope 文件。
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q
find . -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" > cscope.files
cscope -q -R -b -i cscope.files
我的~/.vimrc文件内容如下
set tags+=./tags;/
filetype plugin on
cs add $CSCOPE_DB
我在 .bashrc 中添加了下面一行
export CSCOPE_DB=/home/kadina/build/platform/component/platform/stb/cscope.out
而且我已经从互联网上下载了 cscope_maps.vim 并将其放在 ~/.vim/plugin/
但是当我试图通过 ctrl + } 查找函数的定义时,它列出了所有具有相同名称的函数定义,而不是导航到正确的函数。
例如,当我试图找到 VZ_DIAGNOSTICS::getInstance() 的定义时,它并没有导航到 VZ_DIAGNOSTICS::getInstance() 的定义,而是列出了所有带有命名为 getInstance().
当我试图通过 ctrl + \ + c 查找谁在调用此函数时,我遇到了同样的问题。它列出了调用 getInstance() 的函数,而不是列出调用 VZ_DIAGNOSTICS::getInstance().
的函数任何人都可以让我知道我需要进行哪些更改才能正常工作吗?
因为它使用cstags而不是ctags。
这是我使用的配置。我不安装 cscope_maps.vim 因为我不需要 cscope 的键盘快捷键。
set nocscopetag
禁用 cstags。其他东西使它在 git 项目中自动加载 cscope.out 而无需环境变量。
set nocscopetag
if filereadable("cscope.out")
cscope add cscope.out
else
let git_path = finddir('.git', '.;')
let cscope_path = git_path . "/../cscope.out"
let proj_dir = git_path . "/../"
if filereadable(cscope_path)
execute "cscope add " . cscope_path . ' ' . proj_dir
endif
endif