ubuntu 中安装Git、Vim、Ycm

时间:2020-12-18 17:28:20

安装git

sudo apt-get install git
git config --global user.name "rayfengleixing"
git config --global user.email "290844480@qq.com"
ssh-keygen -C '290844480@qq.com' -t rsa     # 一路回车

复制 ~/.ssh/id_rsa.pub 中的所有内容
登录github.com,个人设置中选中ssh× 项
选SSH title随便取
下面粘贴刚才复制的内容
就可以用git安装了

安装vundle

git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim安装前准备
sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \
    libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
    libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
    python3-dev ruby-dev lua5.1 lua5.1-dev

移除你已经安装的vim

sudo apt-get remove vim vim-runtime gvim

或者是下面的

dpkg -l | grep vim
sudo dpkg -P vim vim-common vim-run

安装vim

cd ~
git clone https://github.com/vim/vim.git

cd vim
./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            #--enable-pythoninterp=yes \
            #--with-python-config-dir=/usr/lib/python2.7/config \
            --enable-python3interp=yes \
            --with-python3-config-dir=/usr/lib/python3.6/config \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk2 --enable-cscope --prefix=/usr
            
make VIMRUNTIMEDIR=/usr/share/vim/vim80

sudo make install
设置vim作为你的默认编辑器:
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1
sudo update-alternatives --set editor /usr/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1
sudo update-alternatives --set vi /usr/bin/vim

安装YouCompleteMe

确保vimrc vundle中有且已安装
Plugin 'Valloric/YouCompleteMe’

如果不需要 C 家族的语义化补全,则可跳过这一步

sudo apt-get install llvm-3.9 clang-3.9 libclang-3.9-dev libboost-all-dev
mkdir ~/.ycm_build
cd ~/.ycm_build
cmake -G "Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DEXTERNAL_LIBCLANG_PATH=/usr/lib/x86_64-linux-gnu/libclang-3.9.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

or test this:

cmake -G "Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DEXTERNAL_LIBCLANG_PATH=/usr/lib/llvm-3.9/lib/libclang.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
cmake --build . --target ycm_core
cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/

~/.vimrc中添加:

let g:ycm_server_python_interpreter='/usr/bin/python'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'