I know 你完成了我 https://github.com/Valloric/YouCompleteMe基于 LLVM,但我想使用OmniCppComplete http://www.vim.org/scripts/script.php?script_id=1520。如果我使用的话,这很好用修改的标头 http://www.vim.org/scripts/script.php?script_id=2358对于C++。此修改后的标头已过时,并且不包含 C++11 中的任何内容。
如果注意到我可以自己修改我的标题,例如:
$ find . -name '*.h' | xargs sed -i 's/__STL_BEGIN_NAMESPACE/namespace std {/'
$ find . -name '*.h' | xargs sed -i 's/__STL_END_NAMESPACE/}/'
或者使用这个设置:
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
两者都不起作用,当然大多数标头没有任何文件扩展名。我已经尝试通过使用文件列表来解决此问题。如何在当前 GCC 的基础上创建工作 CTAGS(例如 /usr/include/c++/...)?常见的方式是什么?
谢谢
如果我尝试从 LIBSTDC++ 完成某些操作,这就是我得到的结果:
std::fs
Omni completion (^O^N^P) Back at original
Ctrl+x, Ctrl+o
Omni completion (^O^N^P) Pattern not found
最后我绝望地给作者写了一封电子邮件修改的标头 http://www.vim.org/scripts/script.php?script_id=2358对于 LIBSTDC++ (GCC)。他很快回答了我(谢谢!):
要求:
安装 vim 和 vim-omnicppcomplete 以及 ctags(vim-omnicppcomplete 的依赖项)。
解决方案:
$ cp -R /usr/include/c++/$GCC_VERSION ~/.vim/cpp_src
# it is not necessary to rename headers without an extension
# replace the "namespace std _GLIBCXX_VISIBILITY(default)" with "namespace std"
$ find . -type f | xargs sed -i 's/namespace std _GLIBCXX_VISIBILITY(default)/namespace std/'
$ ctags -f cpp_tags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -I _GLIBCXX_NOEXCEPT cpp_src
编辑你的~/.vimrc:
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/cpp_tags
" build tags of your own project with Ctrl-F12
map <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q -I _GLIBCXX_NOEXCEPT .<CR>
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
" also necessary for fixing LIBSTDC++ releated stuff
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
Autocompletion for LIBSTDC++ should now work within vim!
Manuall autocomplete with Ctrl+x -> Ctrl+o.
如果您仍然遇到自动完成问题,您可能会在以下位置找到解决方案:文档 https://github.com/FromtonRouge/OmniCppComplete/blob/master/doc/omnicppcomplete.txt(参见常见问题解答 7)。
Bye
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)