vim – YouCompleteMe和Syntastic兼容性?

前端之家收集整理的这篇文章主要介绍了vim – YouCompleteMe和Syntastic兼容性?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想要做的是让YouCompleteMe做完成和Syntastic来检查错误,但它看起来不会在一起.

当YouCompleteMe被禁用时,Synatstic会工作,反之亦然.
但是当两者都启用时,完成不起作用,并且合成不会显示任何错误.

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

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

  1. "
  2. " YouCompleteMe options
  3. "
  4.  
  5. let g:ycm_register_as_syntastic_checker = 1
  6.  
  7. "YCM will put icons in Vim's gutter on lines that have a diagnostic set.
  8. "Turning this off will also turn off the YcmErrorLine and YcmWarningLine
  9. "highlighting
  10. let g:ycm_enable_diagnostic_signs = 1
  11. let g:ycm_enable_diagnostic_highlighting = 0
  12. let g:ycm_always_populate_location_list = 1 "default 0
  13. let g:ycm_open_loclist_on_ycm_diags = 1 "default 1
  14.  
  15.  
  16. let g:ycm_complete_in_strings = 1 "default 1
  17. let g:ycm_collect_identifiers_from_tags_files = 1 "default 0
  18. let g:ycm_path_to_python_interpreter = '' "default ''
  19.  
  20.  
  21. let g:ycm_server_use_vim_stdout = 0 "default 0 (logging to console)
  22. let g:ycm_server_log_level = 'info' "default info
  23.  
  24.  
  25. let g:ycm_global_ycm_extra_conf = '' "where to search for .ycm_extra_conf.py if not found
  26. let g:ycm_confirm_extra_conf = 1
  27.  
  28.  
  29. let g:ycm_goto_buffer_command = 'same-buffer' "[ 'same-buffer','horizontal-split','vertical-split','new-tab' ]
  30. let g:ycm_filetype_whitelist = { '*': 1 }
  31. let g:ycm_key_invoke_completion = '<C-Space>'
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. "
  41. " syntastic settings
  42. "
  43.  
  44. let g:syntastic_enable_signs = 1
  45. let g:syntastic_auto_loc_list = 1
  46. let g:syntastic_check_on_open = 1
  47. let g:syntastic_always_populate_loc_list = 1
  48.  
  49.  
  50. let g:syntastic_cpp_checkers = ['gcc']
  51.  
  52. let g:syntastic_auto_jump = 1
  53. let g:syntastic_enable_balloons = 1
  54.  
  55. let g:syntastic_cpp_compiler = 'g++'
  56. let g:syntastic_cpp_compiler_options = '-std=c++11 -Wall -Wextra'
  57.  
  58.  
  59.  
  60. let g:syntastic_cpp_check_header = 1
  61. let g:syntastic_cpp_auto_refresh_includes = 1
  62.  
  63. "let b:syntastic_cpp_cflags = '-I/home/user/dev/cpp/boost_1_55_0'
  64. let g:syntastic_cpp_include_dirs = [
  65. \ '/opt/boost_1_55_0',\ '/opt/cryptopp-5.6.2',\ '/opt/llvm_install/include/llvm',\ '/opt/llvm_install/include/clang' ]
这是我修改后的.vimrc版本(仅限YCM设置)文件,以便现在使用这些设置YouCompleteMe可以使用我不再需要任何合成功能的所有功能,因为它不需要,除了只有2,这是自动打开的位置列表并自动跳转错误.
  1. "
  2. " YouCompleteMe options
  3. "
  4.  
  5. let g:ycm_register_as_syntastic_checker = 1 "default 1
  6. let g:Show_diagnostics_ui = 1 "default 1
  7.  
  8. "will put icons in Vim's gutter on lines that have a diagnostic set.
  9. "Turning this off will also turn off the YcmErrorLine and YcmWarningLine
  10. "highlighting
  11. let g:ycm_enable_diagnostic_signs = 1
  12. let g:ycm_enable_diagnostic_highlighting = 0
  13. let g:ycm_always_populate_location_list = 1 "default 0
  14. let g:ycm_open_loclist_on_ycm_diags = 1 "default 1
  15.  
  16.  
  17. let g:ycm_complete_in_strings = 1 "default 1
  18. let g:ycm_collect_identifiers_from_tags_files = 0 "default 0
  19. let g:ycm_path_to_python_interpreter = '' "default ''
  20.  
  21.  
  22. let g:ycm_server_use_vim_stdout = 0 "default 0 (logging to console)
  23. let g:ycm_server_log_level = 'info' "default info
  24.  
  25.  
  26. let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' "where to search for .ycm_extra_conf.py if not found
  27. let g:ycm_confirm_extra_conf = 1
  28.  
  29.  
  30. let g:ycm_goto_buffer_command = 'same-buffer' "[ 'same-buffer','new-tab' ]
  31. let g:ycm_filetype_whitelist = { '*': 1 }
  32. let g:ycm_key_invoke_completion = '<C-Space>'
  33.  
  34.  
  35. nnoremap <F11> :YcmForceCompileAndDiagnostics <CR>

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

来自源的Vim在构建之前应用到源中的所有最新补丁.
llvm clang库(最新稳定版)源自源码.
YCM建立了支持新鲜的clang libs.

设置.ycm_extra_conf.py文件也很重要. (标志和主要包括)
这里是地雷:(如果你想看到它们,请向下滚动)

  1. flags = [
  2. '-Wall','-Wextra','-std=c++11','c++',#Standard includes
  3. '-isystem','/usr/include/c++/4.7',#GTK includes
  4. '-isystem','/usr/include/gtk-3.0','-isystem','/usr/include/glib-2.0','/usr/include/glib-2.0/glib','/usr/lib/i386-linux-gnu/glib-2.0/include','/usr/include/pango-1.0','/usr/include/cairo','/usr/include/gdk-pixbuf-2.0','/usr/include/atk-1.0','-I/usr/include/gio-unix-2.0','-I/usr/include/freetype2','-I/usr/include/pixman-1','-I/usr/include/libpng12',#current dir
  5. '-I','.',#custom libraries
  6. '-I','/opt/boost_1_55_0','-I','/opt/cryptopp-5.6.2','/opt/llvm_install/include'
  7. ]

如果您进行GTK编码,那么此列表可能对您有所帮助.
顺便说一下,如果你想知道在包含dir之前系统的意思是什么,这意味着YouCompleteMe(clang / clang编译器)现在将显示这些标题中的警告和错误. (99%的时间都是假阳性)

顺便说一下,使用clang编译器进行Sinastic检查(后台编译),当然,构建它时可以使用任何编译器类型完成.

谢谢!

猜你在找的Bash相关文章