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>
This is the part of ~/.vimrc
related to ycm
.
Also, flags
in .ycm_extra_conf.py
contains the result of echo | gcc -std=c++11 -v -E -x c++ -
echo | gcc -std=c++11 -v -E -x c++ -
which refers to include paths for C-family
.
The problem
While auto-complete
works fine, GoToDefinition
doesn't work at all.
(Here what works
means, ycm
can recognize local header file in projects.)
According to the NOTE , GoToDefinition
only works in the current translation unit
.
However, GoToDefinition
only works in the file being edited in my case.
What I tried: Give up to make .ycm_extra_conf.py
global
.ycm_extra_conf.py
into the top of project and modify g:ycm_global_ycm_extra_conf
in ~/.vimrc
. YcmForceCompileAndDiagnostics
final_flags
in FlagsForFile
function in .ycm_extra_conf.py
file . final_flags
was like this. ['-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
still gives me ' RuntimeError: Can't jump to definition.
' How can I make GoToDefinition
work?
It can't recognize not only indirectly included header files but also directly included header files.
You can see the additional details in here .
What I'd misunderstood is in the comment written by @puremourning.
I recommend you to read this comment first.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.