歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> 學習Linux

Vim安裝YouCompleteMe插件與Python補全插件jedi-vim

Vim安裝YouCompleteMe插件與Python補全插件jedi-vim


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學習指南

快速學會 Vi編輯器

強大的Vim 編輯器

在CentOS 6.2上搭建Vim開發環境

把Vim打造成優秀的C++ IDE 

Vim技巧分享:C語言設置

Ubuntu中設置Vim的行號

本文永久更新鏈接地址:

http://xxxxxx/Linuxjc/1145147.html TechArticle

Copyright © Linux教程網 All Rights Reserved