vim插件管理器: vim-plug
目前只用过vim-plugvim-plug 和Vundle, 但感觉vim-plug要好一点.
例如, 有一次在配置ALE(Asynchronization Lint Engine, 一种动态语法检测工具)时, 发现并不是想让这个工具默认就自动开启. 查看ALE的帮助, 发现有个配置项: let g:ale_enabled = 0. 如果是用Vundle, 则在.vimrc中设置let g:ale_enabled = 0时, 发现没法生效, 但是如果用vim-plug, 则可以生效. 网上有人说, plugin是在vimrc加载后加载(How to disable ale plugin by default in Vim?)
第二点, 感觉vim-plug下载插件的速度比Vundle更快.
安装vim-plug插件管理器
一般建议是在~/.vimrc中这么写:
见: https://github.com/junegunn/vim-plug/wiki/tips
" Place the following code in your .vimrc before plug#begin() call
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
但是上述下载总是出现问题, 手工进行以下下载也不行:
root@ukylin:/home/mg/.vim/autoload# cd ..
root@ukylin:/home/mg/.vim# curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
me@ukylin:~/.vim/autoload$ wget https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
--2020-08-10 06:16:46-- https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 0.0.0.0, ::
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|0.0.0.0|:443... failed: Connection refused.
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|::|:443... failed: Connection refused.
me@ukylin:~/.vim/autoload$
后来经过网上搜索相关资料, 发现可以直接下载github中的vim-plug, 并将plug.vim放到对应目录下即可:
cd ~/下载
git clone https://github.com/junegunn/vim-plug
mkdir ~/.vim/autoload
cp vim-plug/plug.vim ~/.vim/autoload/
参考链接: https://blog.csdn.net/AngelLover2017/article/details/107396055
~/.vimrc中关于vim-plug的配置
这部分没啥好说的, 见github中的文档说明即可
https://github.com/junegunn/vim-plug
"===============Plugs managed by vim-plug===================
"vim-plug {
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
"Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
"Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Multiple Plug commands can be written in a single line using | separators
"Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
"Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
"Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using a non-master branch
"Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
"Plug 'fatih/vim-go', { 'tag': '*' }
" Plugin options
"Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
" Plugin outside ~/.vim/plugged with post-update hook
"Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Unmanaged plugin (manually installed and updated)
"Plug '~/my-prototype-plugin'
"
"
" Initialize plugin system
call plug#end()
"}