vim - YouCompleteMe和Syntastic的兼容性?

标签 vim

我想做的是让YouCompleteMe完成操作,并让Syntastic检查错误,但是看起来并没有在一起。

禁用YouCompleteMe时,Synatstic起作用,反之亦然。
但是同时启用这两种功能时,补全将不起作用,并且合奏不会显示任何错误。

我需要什么配置才能完成这项工作?

这是我的选项:(请注意向下滚动以查看所有选项)

"
" 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' ]

最佳答案

这是我的.vimrc(仅YCM设置)文件的修改版本,因此现在使用这些设置,YouCompleteMe可以使用所有功能+我不再需要任何合成功能,因为除了2外,不需要其他合成功能,并且这是自动打开的位置列表并自动跳转到错误。

"
" 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>

我还可以补充一点,为了使YCM在完全支持下工作,我从源代码构建了以下代码:

来自源的Vim +构建之前应用到源中的所有最新补丁。
从源代码构建的llvm + clang库(最新稳定版)。
YCM建立了对新的clang库的支持。

设置.ycm_extra_conf.py文件也很重要。 (标记,主要包括)
这是地雷:(如果您想全部看到它们,请向下滚动)
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'
]

如果您进行GTK +编码,则此列表可能会对您有所帮助。
顺便说一句,如果您想知道-isystem在包含dir之前是什么意思,则意味着YouCompleteMe(clang/clang++编译器)现在将显示来自这些 header 的警告和错误。 (99%的时间是假阳性)

顺便说一句,Sinastic检查是使用clang编译器(后台编译)完成的,而自行构建它可以使用任何编译器进行。

谢谢!

关于vim - YouCompleteMe和Syntastic的兼容性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24500281/

相关文章:

ruby - VIM中映射命令时的文件补全

regex - 匹配分隔列表中的最后一个元素?

vim - 我怎样才能保留 Vim 撤消历史但不允许隐藏修改过的缓冲区?

vim - 这是vim的bug吗? vit 省略了最后一个字符

pdf - 通过 vim 使用命令使用 pandoc 将 Markdown 编译为 PDF

latex - 在 Ubuntu 上正确的 vim-latex 配置

regex - 使用 vim regexp 清除文件中的前导零

vim - Emacs 相当于 Vim 的单词运动和改变行内单词

linux - 在 vimrc 中切换匹配

vim - VS 代码 Vim : How do you highlight current line?