Vim安裝YouCompleteMe外掛程式與Python補全外掛程式jedi-vim

來源:互聯網
上載者:User

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 locationlistinoremap <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的行號

本文永久更新連結地址:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.