Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preview和tag索引无法恢复问题 #11

Open
xiaoholmes opened this issue Mar 14, 2020 · 4 comments
Open

preview和tag索引无法恢复问题 #11

xiaoholmes opened this issue Mar 14, 2020 · 4 comments

Comments

@xiaoholmes
Copy link

xiaoholmes commented Mar 14, 2020

你好。vim-preview是个比较优秀的插件,但是我目前在使用它时遇到一个很棘手的问题,帮忙看下。
当我preview一些不在tag索引的库的关键词时,preview插件会发生崩溃,再无法使用,并且ctags也无法发生跳转。除非关闭vim,重新打开才能恢复正常。错误如下:
Error detected while processing function 27_PreviewTag[2]..preview#preview_tag[23]..preview#tagfind[2]..preview#taglist:
line 8:
E431: Format error in tags file "/home/.cache/tags/test-prj.tags"
Before byte 386
Error detected while processing function 27_PreviewTag[2]..preview#preview_tag:
line 23:
E171: Missing :endif
Press ENTER or type command to continue

@skywind3000
Copy link
Owner

skywind3000 commented Mar 14, 2020

你 ctags 生成的格式 vim 不识别呗。ctags --version 是什么?

@xiaoholmes
Copy link
Author

ctags生成的格式vim是可以识别的,函数名、变量等ctags索引过的变量都可以正常跳转。如果不小心preview了其他的非关键字,就会导致上面的错误,并且后面即使索引正常的函数名等关键字都无法恢复跳转了(除非vim关闭重启才能恢复正常索引跳转)。
ctags --version版本如下:
Universal Ctags 0.0.0(ee1f32b), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Mar 27 2019, 20:32:24
URL: https://ctags.io/
Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +packcc

@skywind3000
Copy link
Owner

skywind3000 commented Mar 14, 2020

你报错那一行代码,就是 vim 本身内置函数 taglist 的调用,vim 内置函数分析 ctags 数据库时出错了,就是这个意思。

你调用 universal-ctags 的时候有没有增加:

--output-format=e-ctags

这个参数?没加的话 vim 识别会出错。

@xiaoholmes
Copy link
Author

嗯,增加了的,配置应该是和你推荐写的一样,如下所示:

245 if executable('gtags-cscope') && executable('gtags')
246 let g:gutentags_modules += ['gtags_cscope']
247 endif
248
249 " 将自动生成的 tags 文件全部放入 /.cache/tags 目录中,避免污染工程目录
250 let s:vim_tags = expand('
/.cache/tags')
251 let g:gutentags_cache_dir = s:vim_tags
252 " 检测 ~/.cache/tags 不存在就新建
253 if !isdirectory(s:vim_tags)
254 silent! call mkdir(s:vim_tags, 'p')
255 endif
256
257 " change focus to quickfix window after search (optional).
258 let g:gutentags_plus_switch = 1
259
260 " 配置 ctags 的参数
261 let g:gutentags_ctags_extra_args = ['--fields=+niazKS', '--extras=+q']
262
263 let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
264 let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
266
267 " set cscopetag "使用cscope作为tags命令
268 " set cscopeprg='gtags-cscope' "使用gtags-cscope代替cscope
269
270 " 如果使用 universal ctags 需要增加下面一行
271 let g:gutentags_ctags_extra_args += ['--output-format=e-ctags']
272 let g:gutentags_auto_add_gtags_cscope = 1

你可以试着让光标在某个非索引库的关键词上(例如在某一个符号上),然后PreviewTag,看会报上面的错吗?而且后面让光标在某个正常索引库的关键词上时,它还会能被正确索引吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants