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
部分
此外,flags
中的.ycm_extra_conf.py
包含echo | gcc -std=c++11 -v -E -x c++ -
的结果,其中包含C-family
的包含路径。
问题
虽然auto-complete
工作正常,但GoToDefinition
根本不起作用
(这里works
表示ycm
可以识别项目中的本地头文件。)
根据{{3}},GoToDefinition
仅适用于当前的translation unit
但是,GoToDefinition
仅适用于我的案例中正在编辑的文件。
我尝试了什么:放弃制作.ycm_extra_conf.py
全球
.ycm_extra_conf.py
复制到项目顶部,然后修改g:ycm_global_ycm_extra_conf
中的~/.vimrc
。YcmForceCompileAndDiagnostics
final_flags
NOTE中FlagsForFile
函数中的.ycm_extra_conf.py
。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']
GoToDefinition
仍然给了我'RuntimeError: Can't jump to definition.
'如何让GoToDefinition
工作?
它不仅无法识别间接包含的头文件,还直接包含头文件。