-
vundle是管理插件的插件
安装方法需要git
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
如果没有目录,在.vim 目录下
cd ~
mkdir .vim
cd .vim
mkdir bundle
用法
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin '你的插件' "在这里插入插件名
call vundle#end()
filetype plugin indent on
然后在vim中输入:BundleInstall 或:PluginInstall
安装完毕后会显示Done
-
安装youcompleteme
也可以用git安装下载,这里选择用vundle来安装。在上面的代码的中,插入
Plugin 'Valloric/YouCompleteMe'
在 vim中使用:PluginInstall 来安装。但是此时装到一半就没动静了,也不知道状态。直接进入~/.vim/bundle/YouCompleteMe/ 目录下,执行install.sh 或install.py 提示没有下载完,需要执行
git submodule update --init --recursive
或者用
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
来下载。
此时切换到~/.vim/bundle/YouCompleteMe,运行:
python install.py --clang-completer --system-libclang
这里第一个参数是安装c语言的补全,后一个参数表示使用系统的clang,网上的说法是不用自己带的clang运行会崩。所以没有clang的话,需要先执行
sudo apt-get install clang
配置文件,从网上找的,其他配置以后再研究研究
set ts=4 set expandtab set shiftwidth=4 set softtabstop=4 set number "vundle" filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' Plugin 'Valloric/YouCompleteMe' Plugin 'davidhalter/jedi-vim' call vundle#end() filetype plugin indent on "youcompleteme" "默认配置文件路径" let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py' "配置全局路径 "log" "let g:ycm_server_keep_logfiles=1 "let g:ycm_sever_log_level='debug' "打开vim时不再询问是否加载ycm_extra_conf.py配置" "let g:ycm_confirm_extra_conf=0 "set completeopt=longest,menu "python解释器路径" let g:ycm_path_to_python_interpreter='/home/wdh/anaconda3/bin/python3' "let g:ycm_python_binary_path = '/home/wdh/anaconda3/bin/python3' "python 环境 "是否开启语义补全" let g:ycm_seed_identifiers_with_syntax=1 "是否在注释中也开启补全" let g:ycm_complete_in_comments=1 let g:ycm_collect_identifiers_from_comments_and_strings = 0 "开始补全的字符数" let g:ycm_min_num_of_chars_for_completion=2 "补全后自动关机预览窗口" "let g:ycm_autoclose_preview_window_after_completion=1 " 禁止缓存匹配项,每次都重新生成匹配项" let g:ycm_cache_omnifunc=0 "字符串中也开启补全" let g:ycm_complete_in_strings = 1 let g:ycm_seed_identifiers_with_syntax=1 "补全关键字 "离开插入模式后自动关闭预览窗口" autocmd InsertLeave * if pumvisible() == 0|pclose|endif "回车即选中当前项" "inoremap <expr> <CR> pumvisible() ? '<C-y>' : '\<CR>' "上下左右键行为" "inoremap <expr> <Down> pumvisible() ? '\<C-n>' : '\<Down>' "inoremap <expr> <Up> pumvisible() ? '\<C-p>' : '\<Up>' "inoremap <expr> <PageDown> pumvisible() ? '\<PageDown>\<C-p>\<C-n>' : '\<PageDown>' "inoremap <expr> <PageUp> pumvisible() ? '\<PageUp>\<C-p>\<C-n>' : '\<PageUp>'\
特别说明对于c/c++来说,.ycm_extra_conf.py 是从
~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py 或 ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py
拷贝过来的。
如果c/c++的标签有问题,可以打开.ycm_extra_conf.py,修改搜索路径,本次就在flags之间添加了:
'-isystem', '/usr/include/c++/5' '-isystem', '/usr/include/c++/5.4.0',
-
安装jedi
jedi一般都已经包含在anaconda中了,如果没有安装的,可以使用
pip install jedi
在~/.vimrc中添加Plugin ‘davidhalter/jedi-vim’ ,vim中执行:PluginInstall就可以安装jedi。jedi的配置见官网
jedi官网
在使用中不能补全import的包名或者很慢。但是import包之后,函数还是挺齐全的。至于慢的原因和解决方法,留待之后研究。