k-vim 安裝配置

安裝環境

本實驗在centos7.2環境下執行python

yum install -y git python-devel.x86_64 the_silver_searcher cmake wget zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-develtk-devel gdbm-devel db4-devel libpcap-devel xz-devel readline
yum groupinstall -y 'Development Tools'
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

安裝pip

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python ./get-pip.py

# pip 設置代理
1. pip install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple

2. 用戶家目錄下新建.pip目錄 添加pip.conf文件以下
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

安裝pyenv-virtualenv

curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

# 添加到/etc/profile
export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

# soure一下添加到當前環境變量
source /etc/profile

安裝Python3.6

# 先添加環境變量  否則後邊安裝YCM會有坑!!!
export PYTHON_CONFIGURE_OPTS="--enable-shared"
pyenv install  3.6.1

# 安裝本地軟件包的方法
# 指定安裝URL
export PYTHON_BUILD_MIRROR_URL="http://127.0.0.1:8000/"
# 到含有軟件包的目錄下運行
python -m SimpleHTTPServer 8000
# 而後新開一個終端執行
pyenv install 3.6.1
# 這時第一個終端會報錯
"HEAD /a01810ddfcec216bcdb357a84bfaafdfaa0ca42bbdaa4cb7ff74f5a9961e4041 HTTP/1.1" 404 -
# 而後把python安裝包命名爲a01810ddfcec216bcdb357a84bfaafdfaa0ca42bbdaa4cb7ff74f5a9961e4041從新安裝便可
mv ./Python-3.6.1.tar.xz  ./a01810ddfcec216bcdb357a84bfaafdfaa0ca42bbdaa4cb7ff74f5a9961e4041
# 這時候再次安裝,pyenv就會到本地下載軟件包
pyenv install 3.6.1
# 切換到3.6.1版本
pyenv global 3.6.1

編譯安裝vim

# 編譯安裝vim是爲了讓vim支持python3
# 這裏之因此把python2也加進去編譯是由於不添加python2支持會致使安裝YCM後沒法打開vim
wget ftp://ftp.vim.org/pub/vim/unix/vim-8.0.tar.bz2 -O vim-8.0.tar.bz2
tar -xvf ./vim-8.0.tar.bz2
cd ./vim80
./configure --with-features=huge \
            --enable-multibyte \
            --enable-pythoninterp=yes \
            --with-python-config-dir=/usr/lib64/python2.7/config \
            --enable-python3interp=yes \
            --with-python3-config-dir=/root/.pyenv/versions/3.6.1/lib/python3.6/config-3.6m-x86_64-linux-gnu \
            --enable-gui=gtk3 --enable-cscope --prefix=/data/vim80

make && make install

# 備份 vi
mv /usr/bin/vi /usr/bin/vi.bak
ln -s /data/vim80/bin/vim /usr/bin/vi
# 檢查vim  輸出中有+python3便可
vi --version

編譯安裝clang

# 這裏編譯clang是爲了等下編譯YCM做準備. (PS:萬惡的YCM)
wget http://releases.llvm.org/3.3/llvm-3.3.src.tar.gz
wget http://releases.llvm.org/3.3/cfe-3.3.src.tar.gz
wget http://releases.llvm.org/3.3/clang-tools-extra-3.3.src.tar.gz
wget http://releases.llvm.org/3.3/compiler-rt-3.3.src.tar.gz
wget http://releases.llvm.org/3.3/libcxx-3.3.src.tar.gz

# 分別解壓

mv cfe-3.3.src clang
mv clang/ llvm-3.3.src/tools/
mv clang-tools-extra-3.3.src extra
mv extra/ llvm-3.3.src/tools/clang/
mv compiler-rt-3.3.src compiler-rt
mv compiler-rt llvm-3.3.src/projects/

mkdir build-3.3
cd ./build-3.3
# 編譯前換回系統默認的Python版本
pyenv global system
../llvm-3.3.src/configure --enable-optimized --enable-targets=host-only
make -j8
make install

安裝k-vim

pip install flake8 yapf
git clone https://github.com/wklken/k-vim.git k-vim
cd k-vim
# 先安裝YCM
mkdir ./bundle
wget -O YouCompleteMe.tar.gz "http://ohpunyak1.bkt.clouddn.com/YouCompleteMe.tar.gz?v=9999"
tar -zxvf ./YouCompleteMe.tar.gz
cd ./YouCompleteMe
CXX="/usr/local/bin/clang++" ./install.py
# 回到 k-vim的目錄
cd ~/k-vim
sh ./install.sh
# 這時候依然會報錯,可是已經能夠用了

配置

vi ~/k-vim/vimrc
# F3 打開目錄樹 360行左右
nnoremap <F3> :NERDTreeToggle  <CR>

# 自動插入文件頭 600行左右
# 判斷文件類型爲py文件則添加一下內容,其餘文件同理
if &filetype == 'python'
    call setline(1,"\#!/usr/bin/env python")
    call append(1,strftime("# %Y-%m-%d %H:%M:%S"))
    call append(1,"\# arthur:Dear")
    call append(1,"\# -*- coding:utf-8 -*-")
endif

# 更換主題 660行左右
" colorscheme solarized
colorscheme molokai
" colorscheme desert
相關文章
相關標籤/搜索