感谢支持
我们一直在努力

Vim安装YouCompleteMe插件与Python补全插件jedi-vim

一、安装YouCompleteMe

1.安装vundle插件
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
2.安装YouCompleteMe
在.vimrc中添加:
Bundle ‘Valloric/YouCompleteMe’
然后进入vim,输入:
:BundleInstall
然后坐等安装……..
结束时有个错误,这是正常的,因为ycm需要手工编译出库文件
cd ~/ .vim/bundle/YouCompleteMe && ./install.sh
期间好像有个报错,提示需要安装了cmake,根据提示安装即可.

CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
  Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
  (Required is at least version "2.6")

这个报错表示没有安装python-dev
执行sudo apt-get install python-dev即可。

安装完成后在.vimrc中添加如下配置

"youcompleteme  默认tab  s-tab 和自动补全冲突
"let g:ycm_key_list_select_completion=['<c-n>']
let g:ycm_key_list_select_completion = ['<Down>']
"let g:ycm_key_list_previous_completion=['<c-p>']
let g:ycm_key_list_previous_completion = ['<Up>']
let g:ycm_confirm_extra_conf=0 "关闭加载.ycm_extra_conf.py提示

let g:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 基于标签引擎
let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项
let g:ycm_cache_omnifunc=0  " 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_seed_identifiers_with_syntax=1    " 语法关键字补全
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>    "force recomile with syntastic
"nnoremap <leader>lo :lopen<CR> "open locationlist
"nnoremap <leader>lc :lclose<CR>    "close locationlist
inoremap <leader><leader> <C-x><C-o>
"在注释输入中也能补全
let g:ycm_complete_in_comments = 1
"在字符串输入中也能补全
let g:ycm_complete_in_strings = 1
"注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = 0

二、安装jedi插件

1.安装jedi-vim
在.vimrc中添加:
Bundle ‘davidhalter/jedi-vim’
然后进入vim运行BundleInstall
2.安装jedi模块
sudo pip install jedi
安装完成.

gethub上的配置说明:
Settings

Jedi is by default automatically initialized. If you don’t want that I suggest you disable the auto-initialization in your .vimrc:

let g:jedi#auto_initialization = 0

There are also some VIM options (like completeopt and key defaults) which are automatically initialized, but you can skip this:

let g:jedi#auto_vim_configuration = 0

You can make jedi-vim use tabs when going to a definition etc:

let g:jedi#use_tabs_not_buffers = 1

If you are a person who likes to use VIM-splits, you might want to put this in your .vimrc:

let g:jedi#use_splits_not_buffers = “left”

This options could be “left”, “right”, “top”, “bottom” or “winwidth”. It will decide the direction where the split open.

Jedi automatically starts the completion, if you type a dot, e.g. str., if you don’t want this:

let g:jedi#popup_on_dot = 0

Jedi selects the first line of the completion menu: for a better typing-flow and usually saves one keypress.

let g:jedi#popup_select_first = 0

Jedi displays function call signatures in insert mode in real-time, highlighting the current argument. The call signatures can be displayed as a pop-up in the buffer (set to 1, the default), which has the advantage of being easier to refer to, or in Vim’s command line aligned with the function call (set to 2), which can improve the integrity of Vim’s undo history.

let g:jedi#show_call_signatures = “1”

Here are a few more defaults for actions, read the docs (:help jedi-vim) to get more information. If you set them to “”, they are not assigned.

NOTE: subject to change!

let g:jedi#goto_command = “d”
let g:jedi#goto_assignments_command = “g”
let g:jedi#goto_definitions_command = “”
let g:jedi#documentation_command = “K”
let g:jedi#usages_command = “n”
let g:jedi#completions_command = “”
let g:jedi#rename_command = “r”

Finally, if you don’t want completion, but all the other features, use:

let g:jedi#completions_enabled = 0

更多Vim相关教程见以下内容

Vim学习指南 http://www.linuxidc.com/Linux/2013-08/89096.htm

快速学会 Vi编辑器 http://www.linuxidc.com/Linux/2013-08/88586.htm

强大的Vim 编辑器 http://www.linuxidc.com/Linux/2013-07/87544.htm

在CentOS 6.2上搭建Vim开发环境 http://www.linuxidc.com/Linux/2013-07/87363.htm

把Vim打造成优秀的C++ IDE  http://www.linuxidc.com/Linux/2016-06/132262.htm

Vim技巧分享:C语言设置 http://www.linuxidc.com/Linux/2012-12/77124.htm

Ubuntu中设置Vim的行号 http://www.linuxidc.com/Linux/2012-12/75485.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-07/133491.htm

赞(0) 打赏
转载请注明出处:服务器评测 » Vim安装YouCompleteMe插件与Python补全插件jedi-vim
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏