Archlinux 安装和配置vim补全插件YouCompleteMe的过程。
參考:
https://github.com/Valloric/YouCompleteMe
https://github.com/gmarik/Vundle.vim
http://www.cnblogs.com/zhongcq/p/3630047.html
先上图,看效果!
YouCompleteMe的C++自己主动补全, syntastic的实时语法检測!
另外,里面还有缩进对齐显示的插件'Yggdroot/indentLine',以及好看的状态栏显示插件'Lokaltog/vim-powerline'
1.用vundle下载YouCompleteMe,syntastic,indentLine和vim-powerline
Bundle 'Valloric/YouCompleteMe'
Bundle 'scrooloose/syntastic'
Bundle 'Lokaltog/vim-powerline'
Bundle 'Yggdroot/indentLine'
2.下载并安装clang
pacman -S clang (编译会得到/usr/lib/libclang.so)
3. 使用上一步编译得到的libclang库
cd ~
mkdir ycm_build
cd ycm_build
cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/lib/libclang.so. ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
make ycm_support_libs
4.配置.vimrc
""""""""""syntastic"""""""""""" let g:syntastic_check_on_open = 1 let g:syntastic_cpp_include_dirs = ['/usr/include/'] let g:syntastic_cpp_remove_include_errors = 1 let g:syntastic_cpp_check_header = 1 let g:syntastic_cpp_compiler = 'clang++' let g:syntastic_cpp_compiler_options = '-std=c++11 -stdlib=libstdc++' "set error or warning signs let g:syntastic_error_symbol = '✗' let g:syntastic_warning_symbol = '⚠' "whether to show balloons let g:syntastic_enable_balloons = 1 """"""""""""YCM"""""""""""""""""""" "let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py' "let g:ycm_collect_identifiers_from_tags_files = 1 set completeopt=longest,menu "让Vim的补全菜单行为与一般IDE一致(參考VimTip1228) autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自己主动关闭预览窗体 inoremap <expr> <space> pumvisible() ? "\<C-y>" : "\<space>" "按空格键即选中当前项 let g:ycm_cache_omnifunc=0 " 禁止缓存匹配项,每次都又一次生成匹配项 let g:ycm_seed_identifiers_with_syntax = 1 let g:ycm_confirm_extra_conf = 0 "在凝视输入中也能补全 let g:ycm_complete_in_comments = 1 "在字符串输入中也能补全 let g:ycm_complete_in_strings = 1 "凝视和字符串中的文字也会被收入补全 let g:ycm_collect_identifiers_from_comments_and_strings = 0 nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处 """""""""""""""""""""""""""""""""""""""""
""""""""""syntastic"""""""""""" let g:syntastic_check_on_open = 1 let g:syntastic_cpp_include_dirs = ['/usr/include/'] let g:syntastic_cpp_remove_include_errors = 1 let g:syntastic_cpp_check_header = 1 let g:syntastic_cpp_compiler = 'clang++' let g:syntastic_cpp_compiler_options = '-std=c++11 -stdlib=libstdc++' "set error or warning signs let g:syntastic_error_symbol = '✗' let g:syntastic_warning_symbol = '⚠' "whether to show balloons let g:syntastic_enable_balloons = 1 """"""""""""YCM"""""""""""""""""""" "let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py' "let g:ycm_collect_identifiers_from_tags_files = 1 set completeopt=longest,menu "让Vim的补全菜单行为与一般IDE一致(參考VimTip1228) autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自己主动关闭预览窗体 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" "回车即选中当前项 let g:ycm_cache_omnifunc=0 " 禁止缓存匹配项,每次都又一次生成匹配项 let g:ycm_seed_identifiers_with_syntax = 1 let g:ycm_confirm_extra_conf = 0 "在凝视输入中也能补全 let g:ycm_complete_in_comments = 1 "在字符串输入中也能补全 let g:ycm_complete_in_strings = 1 "凝视和字符串中的文字也会被收入补全 let g:ycm_collect_identifiers_from_comments_and_strings = 0 nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处 """"""""""""""""""""""""""""""""""""""""" """"""""vimPowerline""""""""' "if want to use fancy,need to add font patch -> git clone git://gist.github.com/1630581.git ~/.fonts/ttf-dejavu-powerline "let g:Powerline_symbols = 'fancy' let g:Powerline_symbols = 'unicode' "''''''''''''''''''''''''''''''''''''''''' "
© 著作权归作者所有
发表评论
![](/_nuxt/img/avatar.1f60510.png)