简体   繁体   English

使vim的YouCompleteMe插件识别旺盛的标签

[英]Make vim's YouCompleteMe plugin recognize exuberant-ctags

I've been trying for hours to get the YouCompleteMe plugin for vim to recognize my exuberant ctags. 我已经尝试了好几个小时才能获得Vim的YouCompleteMe插件,以识别我的旺盛ctags。 Everything else in YouCompleteMe appears to be working, like autocompleting functions from headers and such. YouCompleteMe中的其他所有功能似乎都可以正常工作,例如标头中的自动完成功能等。 I really want it to default to tag files. 我真的希望它默认为标记文件。 Below I've listed my .vimrc a test tags file which is located at ~/.vim/tags/ 在下面,我列出了我的.vimrc测试标签文件,该文件位于~/.vim/tags/

This is my testtags file 这是我的testtags文件

!_TAG_FILE_FORMAT   2   /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED   1   /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert  /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME  Exuberant Ctags //
!_TAG_PROGRAM_URL   http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION   5.9~svn20110310 //
myfunc  test.h  /^void myfunc(int a, int b);$/;"    p   language:C++

The testtags file was generated with the command ctags -R --sort=1 --fields=+l --c++-kinds=+p -f testtags test.h testtags文件是使用命令ctags -R --sort=1 --fields=+l --c++-kinds=+p -f testtags test.h

and my .vimrc file here 还有我的.vimrc文件

syntax on
filetype off

set runtimepath+=~/.vim/bundle/vundle/
call vundle#rc()

Bundle 'gmarik/vundle'
Bundle 'Valloric/YouCompleteMe'

let g:ycm_collect_identifiers_from_tags_files = 1
set tags+=~/.vim/tags/testtags

filetype plugin indent on

The output of entering the vim command :echo tagfiles() is ['/home/jodag/.vim/tags/testtags'] and the command :set filetype? 输入vim命令:echo tagfiles()['/home/jodag/.vim/tags/testtags']和命令:set filetype? is filetype=cpp . filetype=cpp This means that YCM is finding the tag files and recognizing that I'm currently editing a c++ source file but it won't show the myfunc completion when it press Ctrl+Space. 这意味着YCM正在查找标记文件并认识到我当前正在编辑c ++源文件,但是按Ctrl + Space时它不会显示myfunc完成。 Any help in figuring out why this is happening would be greatly appreciated! 找出原因的任何帮助将不胜感激!

So I figured out the solution after posting on the YCM issue tracker. 因此,在发布到YCM问题跟踪器后,我想出了解决方案。 Apparently the tags file is only read when ctrl+space isn't pressed. 显然,仅在未按下ctrl+space时才读取标签文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM