VIM
2020, Jul 03
VIM
sudo apt-get install vim
# reference: https://github.com/ycm-core/YouCompleteMe/wiki/Building-Vim-from-source
# deps
sudo apt install libncurses5-dev libgnome2-dev libgnomeui-dev \
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev uuid-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev \
ruby-dev lua5.1 liblua5.1-dev libperl-dev git
# remove vim
sudo apt remove vim vim-runtime gvim
sudo apt remove vim-tiny vim-common vim-gui-common vim-nox
git clone https://github.com/vim/vim.git
cd vim
git checkout v8.2.1123
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-python3interp=yes \
--with-python3-command=/usr/bin/python3 \
--with-python3-config-dir=$(/usr/bin/python3-config --configdir) \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk2 \
--enable-cscope \
--prefix=/usr/local
make VIMRUNTIMEDIR=/usr/local/share/vim/vim82
sudo make install
# set vim as your default edtior
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
sudo update-alternatives --set editor /usr/local/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1
sudo update-alternatives --set vi /usr/local/bin/vim
vim-plug
vim-plug是一款易用的vim插件管理工具,安装使用都较为简单
# https://github.com/junegunn/vim-plug
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
NERDTree
# https://github.com/preservim/nerdtree
LeaderF
# https://github.com/Yggdroot/LeaderF
YCM
# https://github.com/ycm-core/YouCompleteMe
# reference: https://github.com/ycm-core/YouCompleteMe/wiki/Full-Installation-Guide
git clone https://github.com/ycm-core/YouCompleteMe.git
cd YouCompleteMe/
git submodule update --init --recursive
# install llvm-clang
mkdir ycm_build && cd ycm_build
cmake -G "Unix Makefiles" . ../third_party/ycmd/cpp/
cmake --build . --target ycm_core
cd ../third_party/ycmd/third_party/watchdog_deps/watchdog/
python setup.py build --build-base=build/3 --build-lib=build/lib3
cd ../../../../../
mkdir regex_build && cd regex_build
cmake -G "Unix Makefiles" . ../third_party/ycmd/third_party/cregex/
cmake --build . --target _regex
cd ..
cp ./third_party/ycmd/examples/.ycm_extra_conf.py $HOME
NerdCommenter
# https://github.com/preservim/nerdcommenter
auto-pairs
# https://github.com/jiangmiao/auto-pairs
vim-airline
# https://github.com/vim-airline/vim-airline
# https://github.com/vim-airline/vim-airline-themes
vim-autoformat
# https://github.com/Chiel92/vim-autoformat
.vimrc配置
call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree'
Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
Plug 'preservim/nerdcommenter'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'jiangmiao/auto-pairs'
Plug 'Yggdroot/indentLine'
Plug 'Chiel92/vim-autoformat'
call plug#end()
" leader
let mapleader = ','
let g:mapleader = ','
" syntax
syntax on
" show
set number
set cursorcolumn
set cursorline
set backspace=indent,eol,start
set completeopt=longest,menu,popup
" tab
set expandtab
" indent
set tabstop=2
set shiftwidth=2
set softtabstop=2
set autoindent
autocmd FileType python set tabstop=2 | set shiftwidth=2 | set softtabstop=2 | set expandtab | set autoindent
" search
set hlsearch
set ignorecase
" nerdtree config
map <C-n> :NERDTreeToggle<CR>
" leaderf config
let g:Lf_WindowPosition = 'popup'
let g:Lf_PreviewInPopup = 1
let g:Lf_ShowDevIcons = 0
let g:Lf_ShortcutF = "<leader>ff"
noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
" ycm config
"set runtimepath+=$HOME/repository/vim/YouCompleteMe
let g:ycm_clangd_binary_path = "/usr/local/bin/clangd"
let g:ycm_global_ycm_extra_conf = "$HOME/.ycm_extra_conf.py"
nnoremap <leader>jd :YcmCompleter GoTo<CR>
nnoremap <leader>jf :YcmCompleter Format<CR>
" nerdcommenter config
let g:NERDSpaceDelims = 1
let g:NERDDefaultAlign = 'left'
let g:NERDCommentEmptyLines = 1
let g:NERDTrimTrailingWhitespace = 1
let g:NERDToggleCheckAllLines = 1
" vim-airline config
set laststatus=2
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = '▶'
let g:airline#extensions#tabline#left_alt_sep = '❯'
let g:airline_left_sep = '▶'
let g:airline_left_alt_sep = '❯'
let g:airline_right_sep = '◀'
let g:airline_right_alt_sep = '❮'
" indentLine config
let g:indentLine_color_term = 239
let g:indentLine_char = '┆'
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif