vim插件配置1--插件管理器

vim插件管理器: vim-plug

目前只用过vim-plugvim-plugVundle, 但感觉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()
"}

参考:

VIM配置攻略(最强干货!!!!)

junegunn/vim-plug

tips

Vim-Plug 下载安装

How to disable ale plugin by default in Vim?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值