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
in .ycm_extra_conf.py
contains 结果echo | gcc -std=c++11 -v -E -x c++ -
指的是C-family
.
问题
虽然auto-complete
工作正常,GoToDefinition
但根本不起作用。
(这里的意思works
是,ycm
可以识别项目中的本地头文件。)
根据注释,GoToDefinition
仅适用于当前的translation unit
.
但是,GoToDefinition
仅适用于我正在编辑的文件。我尝试了什么:放弃让
.ycm_extra_conf.py
全球- 复制
.ycm_extra_conf.py
到项目顶部并g:ycm_global_ycm_extra_conf
在~/.vimrc
. - 做
YcmForceCompileAndDiagnostics
- 文件中的签
final_flags
入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
工作?
它不仅不能识别间接包含的头文件,也不能识别直接包含的头文件。