update plug
This commit is contained in:
parent
30253c598a
commit
d266badc76
@ -18,7 +18,7 @@
|
|||||||
" " Any valid git URL is allowed
|
" " Any valid git URL is allowed
|
||||||
" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
|
" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
|
||||||
"
|
"
|
||||||
" " Group dependencies, vim-snippets depends on ultisnips
|
" " Multiple Plug commands can be written in a single line using | separators
|
||||||
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||||
"
|
"
|
||||||
" " On-demand loading
|
" " On-demand loading
|
||||||
@ -40,7 +40,7 @@
|
|||||||
" " Unmanaged plugin (manually installed and updated)
|
" " Unmanaged plugin (manually installed and updated)
|
||||||
" Plug '~/my-prototype-plugin'
|
" Plug '~/my-prototype-plugin'
|
||||||
"
|
"
|
||||||
" " Add plugins to &runtimepath
|
" " Initialize plugin system
|
||||||
" call plug#end()
|
" call plug#end()
|
||||||
"
|
"
|
||||||
" Then reload .vimrc and :PlugInstall to install plugins.
|
" Then reload .vimrc and :PlugInstall to install plugins.
|
||||||
@ -203,7 +203,9 @@ function! plug#end()
|
|||||||
endif
|
endif
|
||||||
let lod = { 'ft': {}, 'map': {}, 'cmd': {} }
|
let lod = { 'ft': {}, 'map': {}, 'cmd': {} }
|
||||||
|
|
||||||
|
if exists('g:did_load_filetypes')
|
||||||
filetype off
|
filetype off
|
||||||
|
endif
|
||||||
for name in g:plugs_order
|
for name in g:plugs_order
|
||||||
if !has_key(g:plugs, name)
|
if !has_key(g:plugs, name)
|
||||||
continue
|
continue
|
||||||
@ -223,6 +225,7 @@ function! plug#end()
|
|||||||
endif
|
endif
|
||||||
call add(s:triggers[name].map, cmd)
|
call add(s:triggers[name].map, cmd)
|
||||||
elseif cmd =~# '^[A-Z]'
|
elseif cmd =~# '^[A-Z]'
|
||||||
|
let cmd = substitute(cmd, '!*$', '', '')
|
||||||
if exists(':'.cmd) != 2
|
if exists(':'.cmd) != 2
|
||||||
call s:assoc(lod.cmd, cmd, name)
|
call s:assoc(lod.cmd, cmd, name)
|
||||||
endif
|
endif
|
||||||
@ -249,7 +252,7 @@ function! plug#end()
|
|||||||
|
|
||||||
for [cmd, names] in items(lod.cmd)
|
for [cmd, names] in items(lod.cmd)
|
||||||
execute printf(
|
execute printf(
|
||||||
\ 'command! -nargs=* -range -bang %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)',
|
\ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)',
|
||||||
\ cmd, string(cmd), string(names))
|
\ cmd, string(cmd), string(names))
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
@ -257,8 +260,8 @@ function! plug#end()
|
|||||||
for [mode, map_prefix, key_prefix] in
|
for [mode, map_prefix, key_prefix] in
|
||||||
\ [['i', '<C-O>', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
|
\ [['i', '<C-O>', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
|
||||||
execute printf(
|
execute printf(
|
||||||
\ '%snoremap <silent> %s %s:<C-U>call <SID>lod_map(%s, %s, "%s")<CR>',
|
\ '%snoremap <silent> %s %s:<C-U>call <SID>lod_map(%s, %s, %s, "%s")<CR>',
|
||||||
\ mode, map, map_prefix, string(map), string(names), key_prefix)
|
\ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix)
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
@ -310,7 +313,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:git_version_requirement(...)
|
function! s:git_version_requirement(...)
|
||||||
if !exists('s:git_version')
|
if !exists('s:git_version')
|
||||||
let s:git_version = map(split(split(s:system('git --version'))[-1], '\.'), 'str2nr(v:val)')
|
let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)')
|
||||||
endif
|
endif
|
||||||
return s:version_requirement(s:git_version, a:000)
|
return s:version_requirement(s:git_version, a:000)
|
||||||
endfunction
|
endfunction
|
||||||
@ -399,7 +402,7 @@ function! s:reorg_rtp()
|
|||||||
|
|
||||||
let s:middle = get(s:, 'middle', &rtp)
|
let s:middle = get(s:, 'middle', &rtp)
|
||||||
let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])')
|
let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])')
|
||||||
let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), 'isdirectory(v:val)')
|
let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)')
|
||||||
let rtp = join(map(rtps, 'escape(v:val, ",")'), ',')
|
let rtp = join(map(rtps, 'escape(v:val, ",")'), ',')
|
||||||
\ . ','.s:middle.','
|
\ . ','.s:middle.','
|
||||||
\ . join(map(afters, 'escape(v:val, ",")'), ',')
|
\ . join(map(afters, 'escape(v:val, ",")'), ',')
|
||||||
@ -498,7 +501,7 @@ function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
|||||||
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_map(map, names, prefix)
|
function! s:lod_map(map, names, with_prefix, prefix)
|
||||||
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
call s:dobufread(a:names)
|
call s:dobufread(a:names)
|
||||||
let extra = ''
|
let extra = ''
|
||||||
@ -510,6 +513,7 @@ function! s:lod_map(map, names, prefix)
|
|||||||
let extra .= nr2char(c)
|
let extra .= nr2char(c)
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
|
if a:with_prefix
|
||||||
let prefix = v:count ? v:count : ''
|
let prefix = v:count ? v:count : ''
|
||||||
let prefix .= '"'.v:register.a:prefix
|
let prefix .= '"'.v:register.a:prefix
|
||||||
if mode(1) == 'no'
|
if mode(1) == 'no'
|
||||||
@ -519,6 +523,7 @@ function! s:lod_map(map, names, prefix)
|
|||||||
let prefix .= v:operator
|
let prefix .= v:operator
|
||||||
endif
|
endif
|
||||||
call feedkeys(prefix, 'n')
|
call feedkeys(prefix, 'n')
|
||||||
|
endif
|
||||||
call feedkeys(substitute(a:map, '^<Plug>', "\<Plug>", '') . extra)
|
call feedkeys(substitute(a:map, '^<Plug>', "\<Plug>", '') . extra)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -572,8 +577,7 @@ function! s:infer_properties(name, repo)
|
|||||||
let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git')
|
let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git')
|
||||||
let uri = printf(fmt, repo)
|
let uri = printf(fmt, repo)
|
||||||
endif
|
endif
|
||||||
let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') )
|
return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri }
|
||||||
return { 'dir': dir, 'uri': uri }
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -747,7 +751,7 @@ function! s:prepare(...)
|
|||||||
for k in ['<cr>', 'L', 'o', 'X', 'd', 'dd']
|
for k in ['<cr>', 'L', 'o', 'X', 'd', 'dd']
|
||||||
execute 'silent! unmap <buffer>' k
|
execute 'silent! unmap <buffer>' k
|
||||||
endfor
|
endfor
|
||||||
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable
|
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell
|
||||||
setf vim-plug
|
setf vim-plug
|
||||||
if exists('g:syntax_on')
|
if exists('g:syntax_on')
|
||||||
call s:syntax()
|
call s:syntax()
|
||||||
@ -951,7 +955,7 @@ function! s:update_impl(pull, force, args) abort
|
|||||||
|
|
||||||
let use_job = s:nvim || s:vim8
|
let use_job = s:nvim || s:vim8
|
||||||
let python = (has('python') || has('python3')) && !use_job
|
let python = (has('python') || has('python3')) && !use_job
|
||||||
let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && s:check_ruby()
|
let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && threads > 1 && s:check_ruby()
|
||||||
|
|
||||||
let s:update = {
|
let s:update = {
|
||||||
\ 'start': reltime(),
|
\ 'start': reltime(),
|
||||||
@ -1149,7 +1153,7 @@ function! s:job_cb(fn, job, ch, data)
|
|||||||
call call(a:fn, [a:job, a:data])
|
call call(a:fn, [a:job, a:data])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:nvim_cb(job_id, data, event) abort
|
function! s:nvim_cb(job_id, data, event) dict abort
|
||||||
return a:event == 'stdout' ?
|
return a:event == 'stdout' ?
|
||||||
\ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) :
|
\ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) :
|
||||||
\ s:job_cb('s:job_exit_cb', self, 0, a:data)
|
\ s:job_cb('s:job_exit_cb', self, 0, a:data)
|
||||||
@ -2009,10 +2013,21 @@ function! s:git_validate(spec, check_branch)
|
|||||||
\ branch, a:spec.branch)
|
\ branch, a:spec.branch)
|
||||||
endif
|
endif
|
||||||
if empty(err)
|
if empty(err)
|
||||||
let commits = len(s:lines(s:system(printf('git rev-list origin/%s..HEAD', a:spec.branch), a:spec.dir)))
|
let [ahead, behind] = split(s:lastline(s:system(printf(
|
||||||
if !v:shell_error && commits
|
\ 'git rev-list --count --left-right HEAD...origin/%s',
|
||||||
let err = join([printf('Diverged from origin/%s by %d commit(s).', a:spec.branch, commits),
|
\ a:spec.branch), a:spec.dir)), '\t')
|
||||||
\ 'Reinstall after PlugClean.'], "\n")
|
if !v:shell_error && ahead
|
||||||
|
if behind
|
||||||
|
" Only mention PlugClean if diverged, otherwise it's likely to be
|
||||||
|
" pushable (and probably not that messed up).
|
||||||
|
let err = printf(
|
||||||
|
\ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n"
|
||||||
|
\ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind)
|
||||||
|
else
|
||||||
|
let err = printf("Ahead of origin/%s by %d commit(s).\n"
|
||||||
|
\ .'Cannot update until local changes are pushed.',
|
||||||
|
\ a:spec.branch, ahead)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user