0
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/youcompleteme/.ycm_extra_conf.py'
let g:ycm_min_num_of_chars_for_completion=1
let g:ycm_confirm_extra_conf=0
let g:ycm_autoclose_preview_window_after_completion = 1 
nnoremap <F5>           :YcmForceCompileAndDiagnostics<CR>
nnoremap <leader>gic    :YcmCompleter GoToInclude<CR>
nnoremap <leader>gdc    :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gdf    :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gip    :YcmCompleter GoToImprecise<CR>
nnoremap <leader>f      :YcmCompleter FixIt<CR>

这是~/.vimrc相关的部分ycm
此外,flagsin .ycm_extra_conf.pycontains 结果echo | gcc -std=c++11 -v -E -x c++ -指的是C-family.

  • 问题
    虽然auto-complete工作正常,GoToDefinition但根本不起作用。
    (这里的意思works是,ycm可以识别项目中的本地头文件。)
    根据注释GoToDefinition仅适用于当前的translation unit.
    但是,GoToDefinition仅适用于我正在编辑的文件。

  • 我尝试了什么:放弃让.ycm_extra_conf.py全球

    1. 复制.ycm_extra_conf.py到项目顶部并g:ycm_global_ycm_extra_conf~/.vimrc.
    2. YcmForceCompileAndDiagnostics
    3. 文件中的签final_flagsFlagsForFile功能。.ycm_extra_conf.py
    4. final_flags是这样的。
      ['-Wall', '-Wextra', '-Werror', '-Wc++98-compat', '-Wno-long-long', '-Wno-variadic-macros', '-fexceptions', '-DN DEBUG', '-DUSE_CLANG_COMPLETER', '-std=c++11', '-x', 'c++', '-isystem', '/home/illuxic/Redbase/../BoostParts', ' -isystem', '/System/Library/Frameworks/Python.framework/Headers', '-isystem', '/home/illuxic/Redbase/../llvm/inc lude', '-isystem', '/home/illuxic/Redbase/../llvm/tools/clang/include', '-I', '/home/illuxic/Redbase/.', '-I', ' /home/illuxic/Redbase/./ClangCompleter', '-isystem', '/home/illuxic/Redbase/./tests/gmock/gtest', '-isystem', '/ home/illuxic/Redbase/./tests/gmock/gtest/include', '-isystem', '/home/illuxic/Redbase/./tests/gmock', '-isystem' , '/home/illuxic/Redbase/./tests/gmock/include', '-isystem', '/usr/include/c++/5', '-isystem', '/usr/include/x86 _64-linux-gnu/c++/5', '-isystem', '/usr/include/c++/5/backward', '-isystem', '/usr/lib/gcc/x86_64-linux-gnu/5/in clude', '-isystem', '/usr/local/include', '-isystem', '/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed', '-isystem ', '/usr/include/x86_64-linux-gnu', '-isystem', '/usr/include']
    5. GoToDefinition仍然给我' RuntimeError: Can't jump to definition.'

我怎样才能GoToDefinition工作?
它不仅不能识别间接包含的头文件,也不能识别直接包含的头文件。

4

1 回答 1

0

您可以在此处查看其他详细信息。
我误解的是@puremourning 写的评论。
我建议您先阅读此评论。

于 2016-11-26T12:22:18.170 回答