vim 8 IDE 开发环境配置
1、升级 vim 到最新版本 :vim8.2.2028
wget -O vim8.2.2028.zip https://github.com/vim/vim/archive/v8.2.2028.zip unzip vim8.2.2028.zip cd vim-8.2.2028/ cd src/ mkdir /usr/local/vim8
编译vim,支持 python3
./configure --with-features=huge --enable-multibyte --enable-cscope --enable-python3interp=yes --with-python-config-dir=/usr/lib64/python3.6/config-3.6m-x86_64-linux-gnu --prefix=/usr/local/vim8/ --with-python3-command=/usr/bin/python3 cp bin/vim /usr/bin/vim cp bin/vim /usr/local/bin/vim
2、安装 cmake
wget https://github.com/Kitware/CMake/releases/download/v3.19.0/cmake-3.19.0-Linux-x86_64.tar.gz
最新版不需要编译,直接可以使用
mv cmake-3.19.0-Linux-x86_64 /usr/local/cmake echo 'export PATH=/usr/local/cmake/bin:$PATH' >> .zshrc source ~/.zshrc
3、安装vimplus
git clone https://github.com/chxuan/vimplus.git cd ./vimplus ./install.sh
4、配置 .vimrc
"=========================================================== call plug#begin() " 目录结构展示插件 Plug 'scrooloose/nerdtree' Plug 'Xuyuanp/nerdtree-git-plugin' " 代码自动补全 Plug 'ycm-core/YouCompleteMe' " 括号自动补全 Plug 'jiangmiao/auto-pairs' Plug 'itchyny/lightline.vim' " 所有的插件必需在这一行之前添加 call plug#end() "required " NERDTree -------------------------------------------------------------- " vim 启动的时候默认开启 NERDTree autocmd VimEnter * NERDTree " 默认光标在右侧文件编辑区 wincmd w autocmd VimEnter * wincmd w " 文件树设置 {{{ " NERDTree开关 map :NERDTreeToggle "当NERDTree为剩下的唯一窗口时自动关闭 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " 修改树的显示图标 let g:NERDTreeDirArrowExpandable = '►' let g:NERDTreeDirArrowCollapsible = '▼' let NERDTreeAutoCenter=1 " 指定鼠标模式(1.双击打开;2.单目录双文件;3.单击打开) let NERDTreeMouseMode=2 " 按下 F2 调出/隐藏 NERDTree map :silent! NERDTreeToggle " 将 NERDTree 的窗口设置在 vim 窗口的右侧(默认为左侧) let NERDTreeWinPos="right" " 显示行号 let NERDTreeShowLineNumbers=1 " 是否显示隐藏文件 let NERDTreeShowHidden=1 " 设置宽度 let NERDTreeWinSize=25 " 在终端启动vim时,共享NERDTree let g:nerdtree_tabs_open_on_console_startup=1 " 忽略以下文件的显示 let NERDTreeIgnore=['\.pyc','\~$','\.swp'] "let g:NERDTreeIndicatorMapCustom = { let g:NERDTreeGitStatusIndicatorMapCustom = { \"Modified" :"✹", \"Staged" :"✚", \"Untracked" :"✭", \"Renamed" :"➜", \"Unmerged" :"═", \"Deleted" :"✖", \"Dirty" :"✗", \"Clean" :"✔︎", \ 'Ignored' : '☒', \"Unknown" :"?" \ } " }}} " ycm -------------------------------------------------------------- " C family Completion Path let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py' " 打开vim时不再询问是否加载ycm_extra_conf.py let g:ycm_confirm_extra_conf=0 " Python Semantic Completion let g:ycm_python_binary_path = 'python3' let g:ycm_autoclose_preview_window_after_completion = 1 " 在注释输入中也能补全 let g:ycm_complete_in_comments = 1 " 在字符串输入中也能补全 let g:ycm_complete_in_strings = 1 " 开启 YCM 基于标签引擎 let g:ycm_collect_identifiers_from_tags_files=1 " 注释和字符串中的文字也会被收入补全 let g:ycm_collect_identifiers_from_comments_and_strings = 1 let g:syntastic_cpp_compiler = 'g++' let g:syntastic_cpp_compiler_options = '-std=c++11 -stdlib=libc++' " 语言关键字补全, 不过python关键字都很短,所以,需要的自己打开 let g:ycm_seed_identifiers_with_syntax=1 let g:ycm_collect_identifiers_from_tags_files = 1 " 从第2个键入字符就开始罗列匹配项 let g:ycm_min_num_of_chars_for_completion=2 "mapping nmap gd :YcmDiags " 跳转到申明处 nnoremap gl :YcmCompleter GoToDeclaration " 跳转到定义处 nnoremap gf :YcmCompleter GoToDefinition nnoremap gg :YcmCompleter GoToDefinitionElseDeclaration " 对指定源文件,输入两个字母后即触发语义补全 let g:ycm_semantic_triggers = { \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'], \ 'cs,lua,javascript': ['re!\w{2}'], \ } let g:ycm_filetype_whitelist = { \"c":1, \"cpp":1, \"go":1, \"python":1, \"sh":1, \"zsh":1, \ } " 黑名单,不启用 let g:ycm_filetype_blacklist = { \ 'tagbar' : 1, \ 'gitcommit' : 1, \ } "=========================================================== set autoindent " Indent according to previous line. set expandtab " Use spaces instead of tabs. set softtabstop =4 " Tab key indents by 4 spaces. set shiftwidth =4 " >> indents by 4 spaces. set shiftround " >> indents to next multiple of 'shiftwidth'. set hidden " Switch between buffers without having to save first. set display =lastline " Show as much as possible of the last line. set ttyfast " Faster redrawing. set lazyredraw " Only redraw when necessary. set splitbelow " Open new windows below the current window. set splitright " Open new windows right of the current window. set cursorline " Find the current line quickly. set wrapscan " Searches wrap around end-of-file. set report =0 " Always report changed lines. set synmaxcol =120 " Only highlight the first 200 columns. set number set list " Show non-printable characters. if has('multi_byte') && &encoding ==# 'utf-8' let &listchars = 'tab:▸ ,extends:❯,precedes:❮,nbsp:±' else let &listchars = 'tab:> ,extends:>,precedes:<,nbsp:.' endif " Put all temporary files under the same directory. let s:vim_backup = expand("$HOME/.vim/files/backup/") if !isdirectory(s:vim_backup) silent! call mkdir(s:vim_backup, 'p') endif let s:vim_swap = expand("$HOME/.vim/files/swap/") if !isdirectory(s:vim_swap) silent! call mkdir(s:vim_swap, 'p') endif let s:vim_undo = expand("$HOME/.vim/files/undo/") if !isdirectory(s:vim_undo) silent! call mkdir(s:vim_undo, 'p') endif let s:vim_info = expand("$HOME/.vim/files/info/") if !isdirectory(s:vim_info) silent! call mkdir(s:vim_info, 'p') endif set backup set backupdir =$HOME/.vim/files/backup/ set backupext =-vimbackup set backupskip = set directory =$HOME/.vim/files/swap/ set updatecount =100 set undofile set undodir =$HOME/.vim/files/undo/ set viminfo ='100,n$HOME/.vim/files/info/viminfo " 取消换行 set nowrap " 为方便复制,用开启/关闭行号显示 nnoremap :set nonumber!:set foldcolumn=0
5、安装YouCompleteMe
vimplus自动安装好之后 YouCompleteMe在系统的 ~/.vim/plugged/YouCompleteMe 路径下
先删除之前装的YouCompleteMe目录:
rm -rf ~/.vim/plugged/YouCompleteMe
从git上拉取YouCompleteMe
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/plugged/YouCompleteMe #很慢 cd ~/.vim/plugged/YouCompleteMe git submodule update --init --recursive #很慢
等待下载完毕,执行安装命令
./install.py --clang-completer