From 1a1d63222d2a283dcd568a7cd68b16974d1a06b2 Mon Sep 17 00:00:00 2001 From: Nick Nisi Date: Wed, 3 Feb 2016 09:51:35 -0600 Subject: [PATCH] upgrade vim-plug --- config/nvim/autoload/plug.vim | 87 +++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 29 deletions(-) diff --git a/config/nvim/autoload/plug.vim b/config/nvim/autoload/plug.vim index 2a06dc7..3357de5 100644 --- a/config/nvim/autoload/plug.vim +++ b/config/nvim/autoload/plug.vim @@ -11,9 +11,13 @@ " call plug#begin('~/.vim/plugged') " " " Make sure you use single quotes -" Plug 'junegunn/seoul256.vim' +" +" " 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' +" " " Group dependencies, vim-snippets depends on ultisnips " Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' " @@ -21,9 +25,6 @@ " Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " Plug 'tpope/vim-fireplace', { 'for': 'clojure' } " -" " Using git URL -" Plug 'https://github.com/junegunn/vim-github-dashboard.git' -" " " Using a non-master branch " Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } " @@ -40,7 +41,21 @@ " call plug#end() " " Then reload .vimrc and :PlugInstall to install plugins. -" Visit https://github.com/junegunn/vim-plug for more information. +" +" Plug options: +" +"| Option | Description | +"| ----------------------- | ------------------------------------------------ | +"| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use | +"| `rtp` | Subdirectory that contains Vim plugin | +"| `dir` | Custom directory for the plugin | +"| `as` | Use different name for the plugin | +"| `do` | Post-update hook (string or funcref) | +"| `on` | On-demand loading: Commands or ``-mappings | +"| `for` | On-demand loading: File types | +"| `frozen` | Do not update unless explicitly specified | +" +" More information: https://github.com/junegunn/vim-plug " " " Copyright (c) 2015 Junegunn Choi @@ -115,7 +130,7 @@ endfunction function! s:define_commands() command! -nargs=+ -bar Plug call s:add() if !executable('git') - return s:err('`git` executable not found. vim-plug requires git.') + return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') endif command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(0, []) command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(0, []) @@ -450,9 +465,9 @@ function! s:add(repo, ...) try let repo = s:trim(a:repo) - let name = fnamemodify(repo, ':t:s?\.git$??') - let spec = extend(s:infer_properties(name, repo), - \ a:0 == 1 ? s:parse_options(a:1) : s:base_spec) + let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec + let name = get(opts, 'as', fnamemodify(repo, ':t:s?\.git$??')) + let spec = extend(s:infer_properties(name, repo), opts) if !has_key(g:plugs, name) call add(g:plugs_order, name) endif @@ -620,32 +635,41 @@ function! s:switch_out(...) endif endfunction -function! s:prepare() +function! s:finish_bindings() + nnoremap R :silent! call retry() + nnoremap D :PlugDiff + nnoremap S :PlugStatus + nnoremap U :call status_update() + xnoremap U :call status_update() + nnoremap ]] :silent! call section('') + nnoremap [[ :silent! call section('b') +endfunction + +function! s:prepare(...) call s:job_abort() if s:switch_in() - silent %d _ - else - call s:new_window() - nnoremap q :if b:plug_preview==1pcendifbd - nnoremap R :silent! call retry() - nnoremap D :PlugDiff - nnoremap S :PlugStatus - nnoremap U :call status_update() - xnoremap U :call status_update() - nnoremap ]] :silent! call section('') - nnoremap [[ :silent! call section('b') - let b:plug_preview = -1 - let s:plug_tab = tabpagenr() - let s:plug_buf = winbufnr(0) - call s:assign_name() + normal q endif + + call s:new_window() + nnoremap q :if b:plug_preview==1pcendifbd + if a:0 == 0 + call s:finish_bindings() + endif + let b:plug_preview = -1 + let s:plug_tab = tabpagenr() + let s:plug_buf = winbufnr(0) + call s:assign_name() + silent! unmap silent! unmap L silent! unmap o silent! unmap X setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable setf vim-plug - call s:syntax() + if exists('g:syntax_on') + call s:syntax() + endif endfunction function! s:assign_name() @@ -755,6 +779,7 @@ function! s:finish(pull) call add(msgs, "Press 'D' to see the updated changes.") endif echo join(msgs, ' ') + call s:finish_bindings() endfunction function! s:retry() @@ -829,7 +854,7 @@ function! s:update_impl(pull, force, args) abort \ 'fin': 0 \ } - call s:prepare() + call s:prepare(1) call append(0, ['', '']) normal! 2G silent! redraw @@ -840,7 +865,7 @@ function! s:update_impl(pull, force, args) abort " Python version requirement (>= 2.7) if python && !has('python3') && !ruby && !s:nvim && s:update.threads > 1 redir => pyv - silent python import platform; print(platform.python_version()) + silent python import platform; print platform.python_version() redir END let python = s:version_requirement( \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6]) @@ -2017,8 +2042,12 @@ function! s:diff() let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)') call s:progress_bar(2, bar, len(total)) for origin in [1, 0] + let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))')))) + if empty(plugs) + continue + endif call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') - for [k, v] in reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))')))) + for [k, v] in plugs let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..' let diff = s:system_chomp('git log --pretty=format:"%h%x01%d%x01%s%x01%cr" '.s:shellesc(range), v.dir) if !empty(diff)