vimプログラミング構成python 3開発環境初級(2つのバージョン)

20847 ワード

比較的簡単な第2版を直接試してみることをお勧めします
vim第1版(python 3もデフォルトではサポートされていません)
Centos 7.3の付属vimバージョンは7.4で、python 2のみをサポートpython 3はサポートされていないためvim 8にアップグレードされました
1、元vimインストール8.0のvimをアンインストールする
1.yum -y remove vim  
 (        sudo  ,      )
rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm
rpm --import http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7
yum -y remove vim-minimal vim-common vim-enhanced sudo
yum -y --enablerepo=gf-plus install vim-enhanced sudo

2、dirccorsのインストール
git clone https://github.com/seebi/dircolors-solarized.git

cd dircolors-solarized/


mv dircolors.ansi-dark ~/.dircolors
#      
vim /etc/profile
export TERM=xterm-256color
if [ -x /usr/bin/dircolors ]; then
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias tree='tree -C'
fi


3、インストール依存


yum -y install python-devel ruby ruby-devel perl perl-devel perl-ExtUtils-Embed

yum install ncurses-devel

yum install ctags
yum -y install libXt-devel gtk2-devel 
 

4 Python 3.6のインストール
1)       
>: cd ~

2)    Python3.6
  3.6.8
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz

3)     
>:tar xJf Python-3.6.8.tar.xz

4)      

>:cd Python-3.6.8

5)      :/usr/local/python3
>:./configure --prefix=/usr/local/python3

6)     
>: make && sudo make install

7)     :     python3,pip3
>: ln -s /usr/local/python3/bin/python3 /usr/bin/python3
>: ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3



5pipソースの構成:
1)  pip    
>: mkdir ~/.pip

2)          :      
cd ~/.pip && vim pip.conf

[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com

6vendleのインストール
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

touch ~/.vimrc

touch ~/.vimrc.bundles

if &compatible
  set nocompatible
end

filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Plugin 'VundleVim/Vundle.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'tomasr/molokai'
Plugin 'vim-scripts/phd'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'octol/vim-cpp-enhanced-highlight'
Plugin 'derekwyatt/vim-fswitch'
Plugin 'vim-scripts/a.vim'
Plugin 'kshenoy/vim-signature'
Plugin 'vim-scripts/BOOKMARKS--Mark-and-Highlight-Full-Lines'
Plugin 'majutsushi/tagbar'
Plugin 'vim-scripts/indexer.tar.gz'
Plugin 'vim-scripts/DfrankUtil'
Plugin 'vim-scripts/vimprj'
Plugin 'dyng/ctrlsf.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'vim-scripts/DrawIt'
Plugin 'SirVer/ultisnips'
Plugin 'Valloric/YouCompleteMe'
Plugin 'rdnetto/YCM-Generator'
Plugin 'derekwyatt/vim-protodef'
Plugin 'scrooloose/nerdtree'
Plugin 'gcmt/wildfire.vim'
Plugin 'sjl/gundo.vim'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'suan/vim-instant-markdown'
Plugin 'qpkorr/vim-bufkill'
Plugin 'skywind3000/asyncrun.vim'
 if filereadable(expand("~/.vimrc.bundles.local"))
  source ~/.vimrc.bundles.local
endif
filetype on

#   ,       
if &compatible
  set nocompatible
end

filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" Let Vundle manage Vundle
Bundle 'gmarik/vundle'
" Define bundles via Github repos
"     
Bundle 'majutsushi/tagbar'
Bundle 'vim-scripts/ctags.vim'
"       
Bundle 'scrooloose/syntastic'
"     
Bundle 'kien/ctrlp.vim'
"      
Bundle "scrooloose/nerdtree"
"      
Bundle "Lokaltog/vim-powerline"
"     
Bundle "altercation/vim-colors-solarized"
" python    
Bundle 'davidhalter/jedi-vim'
Bundle "klen/python-mode"
"       
Bundle 'kien/rainbow_parentheses.vim'
"      
Bundle 'nathanaelkane/vim-indent-guides'
if filereadable(expand("~/.vimrc.bundles.local"))
  source ~/.vimrc.bundles.local
endif
filetype on                      

7、ダウンロードコンパイルycm

 
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
 
cd ~/.vim/bundle/YouCompleteMe
 
git submodule update --init --recursive
  
     'https://go.googlesource.com/tools'        'third_party/go/src/golang.org/x/tools'cd ~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x

git clone https://github.com/golang/tools.git

#   YouComplateMe            
cd ~/.vim/bundle/YouCompleteMe

#         
git submodule update --init --recursive

8vundelにプラグインをインストールする

Plugin 'gmarik/Vundle.vim'
Plugin 'Valloric/YouCompleteMe’

9\
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
#  
ERROR: Unable to find executable 'cmake'. CMake is required to build ycmd
#  
wget https://cmake.org/files/v3.6/cmake-3.6.2.tar.gz
 
tar xvf cmake-3.6.2.tar.gz && cd cmake-3.6.2/
 
./bootstrap
gmake
gmake install
 

10ycm nodejsとgolangの補完を行う

cd ~/.vim/bundle/YouCompleteMe

./install.py  --clang-completer  --gocode-completer --tern-completer


vim構成第2版
1、.vimrcファイルの構成
# 1.       .vimrc  ,
vim .vimrc


2、プラグインマネージャvim.plugをインストールする
# github      
curl -fLo ~/.vim/autoload/plug.vim --create-dirs     https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
#copy     



公式ケースでは、次の2行を.vimrcファイルに書き込んで、この2行の間に「必要なプラグイン」をインストールする準備をします.
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')

" Initialize plugin system
call plug#end()

3、プラグインのインストール例
#   1,     vim-startify
https://github.com/mhinz/vim-startify
#    ,  .vimrc  plug 
 Plug 'mhinz/vim-startify'
 #  esc,  :
 :source ~/.vimrc
 #    ,   
 :PlugInstall

ステップ図1
[外部リンク画像転送失敗(img-6 IrqUquK-1568016673202)(/Users/bobwang/Library/Application Support/typora-user-images/image-20190907184715608.png)]
ステップ図2
[外部リンク画像転送失敗(img-9 v 8 CkvDV-1560673103)(/Users/bobwang/Library/Application Support/typora-user-images/image-20907185028493.png)]
インストールが完了したら、入力:qaはすべてのウィンドウを終了します
:qa

vimを入力すると、次のような起動表示が表示されます.
[外部リンク画像転送失敗(img-kj 6 gvMmh-1560673104)(/Users/bobwang/Library/Application Support/typora-user-images/image-20190907185524039.png)]
4、その他のプラグインの検索
https://vimawesome.com/

5、常用プラグイン
#1、     
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
#2    
Plug 'yggdroot/indentline'
#3、  
Plug 'w0ng/vim-hybrid'
:colorscheme hybrid     
#             
git clone https://github.com/w0ng/vim-hybrid.git
#      .vim/colors/,      
mkdir  .vim/colors
cp vim-hybrid/colors/hybrid.vim  ./.vim/colors/ 
#      
set background=dark
colorscheme hybrid
#4、   
Plug 'scrooloose/nerdtree'
autocmd vimenter * NERDTree       
#5      
Plug 'ctrlpvim/ctrlp.vim'  
//   ctrl+p         
#6、      easymotion
Plug 'easymotion/vim-easymotion'
#     
nmap ss <Plug>(easymotion-s2)


6、goプラグイン(goの公式サイトにアクセスできることを前提)
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }

7.python mode
Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }

8.自動補完コードdeplete.vim
if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'deoplete-plugins/deoplete-jedi'
let g:deoplete#enable_at_startup = 1
set completeopt-=preview

bug:
vim-hug-neovim-rpc] Vim(pythonx):ModuleNotFoundError: No module named ‘neovim’
#  
pip3 install pynvim

.vimrc構成
set nu
set background=dark
colorscheme murphy
set nocompatible
set encoding=utf-8
set showmatch

call plug#begin('~/.vim/plugged')
 
    Plug 'mhinz/vim-startify'
 
    Plug 'yggdroot/indentline'
 
    Plug 'vim-airline/vim-airline'
    Plug 'vim-airline/vim-airline-themes'
 
    Plug 'w0ng/vim-hybrid'
    Plug 'scrooloose/nerdtree'
    Plug 'ctrlpvim/ctrlp.vim'
    Plug 'easymotion/vim-easymotion'
    Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
if has('nvim')
    Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
    Plug 'Shougo/deoplete.nvim'
    Plug 'roxma/nvim-yarp'
    Plug 'roxma/vim-hug-neovim-rpc'
endif
  	Plug 'deoplete-plugins/deoplete-jedi'
     
call plug#end()
let g:pymode_python = 'python3'
let g:pymode_trim_whitespaces = 1
let g:pymode_doc = 1
let g:pymode_doc_bind = 'K'
let g:pymode_rope_goto_definition_bind = ""
let g:pymode_lint = 1
let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'pylink']
let g:pymode_options_max_line_length = 120

let g:deoplete#enable_at_startup = 1
set completeopt-=preview