What I want to do is to have YouCompleteMe do completions and Syntastic to check for errors but it looks that doesn't go together.
When YouCompleteMe is disabled then Synatstic works, and vice versa. but when both are enabled, completion does not work and syntastic does not show any errors.
What configuration do I need to make this work?
here are my options: (note scroll down to see all the options)
"
" YouCompleteMe options
"
let g:ycm_register_as_syntastic_checker = 1
"YCM will put icons in Vim's gutter on lines that have a diagnostic set.
"Turning this off will also turn off the YcmErrorLine and YcmWarningLine
"highlighting
let g:ycm_enable_diagnostic_signs = 1
let g:ycm_enable_diagnostic_highlighting = 0
let g:ycm_always_populate_location_list = 1 "default 0
let g:ycm_open_loclist_on_ycm_diags = 1 "default 1
let g:ycm_complete_in_strings = 1 "default 1
let g:ycm_collect_identifiers_from_tags_files = 1 "default 0
let g:ycm_path_to_python_interpreter = '' "default ''
let g:ycm_server_use_vim_stdout = 0 "default 0 (logging to console)
let g:ycm_server_log_level = 'info' "default info
let g:ycm_global_ycm_extra_conf = '' "where to search for .ycm_extra_conf.py if not found
let g:ycm_confirm_extra_conf = 1
let g:ycm_goto_buffer_command = 'same-buffer' "[ 'same-buffer', 'horizontal-split', 'vertical-split', 'new-tab' ]
let g:ycm_filetype_whitelist = { '*': 1 }
let g:ycm_key_invoke_completion = '<C-Space>'
"
" syntastic settings
"
let g:syntastic_enable_signs = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_cpp_checkers = ['gcc']
let g:syntastic_auto_jump = 1
let g:syntastic_enable_balloons = 1
let g:syntastic_cpp_compiler = 'g++'
let g:syntastic_cpp_compiler_options = '-std=c++11 -Wall -Wextra'
let g:syntastic_cpp_check_header = 1
let g:syntastic_cpp_auto_refresh_includes = 1
"let b:syntastic_cpp_cflags = '-I/home/user/dev/cpp/boost_1_55_0'
let g:syntastic_cpp_include_dirs = [
\ '/opt/boost_1_55_0',
\ '/opt/cryptopp-5.6.2',
\ '/opt/llvm_install/include/llvm',
\ '/opt/llvm_install/include/clang' ]
Here is my modified version of .vimrc (only YCM settings) file so that now with these settings YouCompleteMe works with all the features + I do not need any of syntastic features any more since it's not needed, except only 2, and that's auto opening of location list and auto jumping to the errors.
"
" YouCompleteMe options
"
let g:ycm_register_as_syntastic_checker = 1 "default 1
let g:Show_diagnostics_ui = 1 "default 1
"will put icons in Vim's gutter on lines that have a diagnostic set.
"Turning this off will also turn off the YcmErrorLine and YcmWarningLine
"highlighting
let g:ycm_enable_diagnostic_signs = 1
let g:ycm_enable_diagnostic_highlighting = 0
let g:ycm_always_populate_location_list = 1 "default 0
let g:ycm_open_loclist_on_ycm_diags = 1 "default 1
let g:ycm_complete_in_strings = 1 "default 1
let g:ycm_collect_identifiers_from_tags_files = 0 "default 0
let g:ycm_path_to_python_interpreter = '' "default ''
let g:ycm_server_use_vim_stdout = 0 "default 0 (logging to console)
let g:ycm_server_log_level = 'info' "default info
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' "where to search for .ycm_extra_conf.py if not found
let g:ycm_confirm_extra_conf = 1
let g:ycm_goto_buffer_command = 'same-buffer' "[ 'same-buffer', 'horizontal-split', 'vertical-split', 'new-tab' ]
let g:ycm_filetype_whitelist = { '*': 1 }
let g:ycm_key_invoke_completion = '<C-Space>'
nnoremap <F11> :YcmForceCompileAndDiagnostics <CR>
I may also add that in order to make YCM work with full support, I built following from source:
Vim from source + all the latest patches applied into the source before the build. llvm + clang libraries (latest stable) built from source. YCM built with support againt fresh clang libs.
Also it's important to setup your .ycm_extra_conf.py file. (flags and includes mainly) here are mines: (scrol down if you want to see them all)
flags = [
'-Wall',
'-Wextra',
'-std=c++11',
'c++',
#Standard includes
'-isystem',
'/usr/include/c++/4.7',
#GTK includes
'-isystem',
'/usr/include/gtk-3.0',
'-isystem',
'/usr/include/glib-2.0',
'-isystem',
'/usr/include/glib-2.0/glib',
'-isystem',
'/usr/lib/i386-linux-gnu/glib-2.0/include',
'-isystem',
'/usr/include/pango-1.0',
'-isystem',
'/usr/include/cairo',
'-isystem',
'/usr/include/gdk-pixbuf-2.0',
'-isystem',
'/usr/include/atk-1.0',
'-isystem',
'-I/usr/include/gio-unix-2.0',
'-isystem',
'-I/usr/include/freetype2',
'-isystem',
'-I/usr/include/pixman-1',
'-isystem',
'-I/usr/include/libpng12',
#current dir
'-I',
'.',
#custom libraries
'-I',
'/opt/boost_1_55_0',
'-I',
'/opt/cryptopp-5.6.2',
'-I',
'/opt/llvm_install/include'
]
If you do GTK+ coding then this list may be of help to you. btw, if you wonder what does -isystem mean right before include dir, it means that YouCompleteMe (clang/clang++ compiler) will now show warnings and errors from these headers. (which are false positive 99% of the time)
btw, Sinastic checking is done with clang compiler (background compiling) while building it self can be done with any compiler kind, of course.
Thanks!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With