[笔记]ubuntu 13.04 配置YouCompleteMe

来源:互联网 发布:淘宝云客服多久结工资 编辑:程序博客网 时间:2024/06/05 06:09

参考 http://www.cnblogs.com/csuftzzk/p/3435710.html  但按照这篇文章,编译会出错,所以部分路径有修改,.vimrc配置略不同;

syntastic插件效果不理想,经常误报,还有就是比较卡。



一、 准备


1. 安装cmake, python-dev

sudo apt-get install cmake python-dev

2. 安装最新的VIM

sudo add-apt-repository ppa:nmi/vim-snapshotssudo apt-get updatesudo apt-get install vim

3. 下载Vundle, Vundle可以管理vim插件,很方便,更多可以参考 http://blog.csdn.net/codebistu/article/details/8257138

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

4. 下载完了vundle后,配置~/.vimrc文件如下,然后打开一个vim窗口,执行命令:BundleInstall, vundle会自动去网上将相关插件下载下来并安装好。要删除一个插件也很简单,先在~/.vimrc中移除该插件条目,然后进入vim执行命令:BundleClean。

set nocompatible              " be iMprovedBundle 'scrooloose/syntastic'set rtp+=~/.vim/bundle/vundle/call vundle#rc()" let Vundle manage Vundle" required!Bundle 'gmarik/vundle'" My bundles here:"" original repos on GitHubBundle 'tpope/vim-fugitive'Bundle 'Lokaltog/vim-easymotion'Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}Bundle 'tpope/vim-rails.git'" vim-scripts reposBundle 'L9'Bundle 'FuzzyFinder'" non-GitHub reposBundle 'git://git.wincent.com/command-t.git'" Git repos on your local machine (i.e. when working on your own plugin)Bundle 'file:///Users/gmarik/path/to/plugin'" ...Bundle 'Valloric/YouCompleteMe'filetype plugin indent on     " required!


5. 编译LLVM+Clang的源代码

mkdir ~/llvmsrccd ~/llvmsrcsvn co http://llvm.org/svn/llvm-project/llvm/trunk llvmcd ~/llvmsrc/toolssvn co http://llvm.org/svn/llvm-project/cfe/trunk clangcd ~/llvmsrc/llvm/projectssvn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rtsvn co http://llvm.org/svn/llvm-project/test-suite/trunk test-suitecd ~/llvmsrc./llvm/configure --enable-optimizedmake


二、配置,编译YouCompleteMe


1. 前面使用vundle已经下载好了YouCompleteMe的源码。


2. 编译

mkdir ~/ycm_buildcd ~/ycm_buildcmake -G "Unix Makefiles"  ~/.vim/bundle/YouCompleteMe/cpp -DEXTERNAL_LIBCLANG_PATH=~/llvmsrc/llvm/Release+Asserts/lib/libclang.somake ycm_coremake ycm_support_libs


3. 配置~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py。使用-isystem标志添加系统的头文件进行解析,而-I标志用于添加第三分的头文件进行解析。在flags最后增加如下:

'-isystem','/usr/include','-isystem','/usr/include/c++/','-isystem','/usr/include/i386-linux-gnu/c++'


4. 此外,为了更好的提高补全效率,我们可以保留原先使用的用Ctags生成的tags文件,并在~/.vimrc中添加:let g:ycm_collect_identifiers_from_tag_files = 1.其中,在vim中使用 :echo tagfiles()可以查看当前使用的tags文件。

5. 我的.vimrc配置内容:

" 去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限set nocompatible" bundle setting au GUIEnter * call libcallnr("vimtweak.dll", "SetAlpha", 234)filetype off                  " required!set completeopt-=previewset rtp+=~/.vim/bundle/vundle/call vundle#rc()" let Vundle manage Vundle" required! Bundle 'gmarik/vundle'" My bundles here:" original repos on GitHubBundle 'tpope/vim-fugitive'Bundle 'Lokaltog/vim-easymotion'Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}Bundle 'tpope/vim-rails.git'" vim-scripts reposBundle 'L9'Bundle 'FuzzyFinder'" non-GitHub reposBundle 'git://git.wincent.com/command-t.git'" Git repos on your local machine (i.e. when working on your own plugin)Bundle 'file:///Users/gmarik/path/to/plugin'Bundle 'Valloric/YouCompleteMe'Bundle 'scrooloose/syntastic'Bundle 'c.vim'Bundle 'a.vim'let g:ycm_collect_identifiers_from_tag_files = 1let g:syntastic_ignore_files=[".*\.py$"]let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'set backspace=indent,eol,startset tabstop=4set shiftwidth=4set expandtabset cindent" 在编辑过程中,在右下角显示光标位置的状态行set rulerset showcmdset hlsearchset incsearchset cino=g0:0          " let class's public: don't indent" F12 run pythonmap <F12> :!/usr/bin/python %" map <c-w><c-t> :Tlist<cr>" map <c-w><c-m> :WMToggle<cr>" map <c-w><c-f> :FirstExplorerWindow<cr>" map <c-w><c-b> :BottomExplorerWindow<cr>":set cscopequickfix=s-,c-,d-,i-,t-,e-":cs add /home/broom/yeast/trunk/cscope.out /home/broom/yeast/trunk/" let g:winManagerWindowLayout='FileExplorer|TagList'":let Tlist_Use_Right_Window=1":nmap wm :WMToggle<cr>nnoremap <silent> <F3> :Grep<CR>" 语法高亮度显示syntax onfiletype plugin indent onset viminfo='20,\"50" 设置历史的行数set history=1000" Only do this part when compiled with support for autocommandsif has("autocmd")    " In text files, always limit the width of text to 78 characters    autocmd BufRead *.txt set tw=78    " When editing a file, always jump to the last cursor position    autocmd BufReadPost *        \ if line("'\"") > 0 && line ("'\"") <= line("$") |        \   exe "normal g'\"" |        \ endifendif" set bg=dark" 显示行号set nuimap <c-w> <Esc>autocmd FileType ruby,eruby set omnifunc=rubycomplete#Completefiletype plugin on"------------------------------------------------------------------------------function! SET_PYTHON_IDENT()set shiftwidth=2set softtabstop=2set tabstop=2set backspace=2set smarttabendfunctionau FileType python,ruby :call SET_PYTHON_IDENT()"c-support year date timelet g:C_FormatDate            = '%Y-%m-%d'let g:C_FormatTime            = '%H:%M:%S'let g:C_FormatYear            = '%Y'" Encoding relatedset encoding=UTF-8" set langmenu=zh_CN.UTF-8" language message zh_CN.UTF-8set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1set fileencoding=utf-8set t_Co=256colorscheme desertEx"colorscheme evening"colorscheme peaksea"colorscheme blackboard       " Ruby蓝色着色模式"colorscheme molokai         " Sublime Text着色模式"colorscheme ubloh           " 突出注释的艳丽着色模式au GUIEnter * call libcallnr("vimtweak.dll", "SetAlpha", 234)


0 0
原创粉丝点击