mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-07 09:34:25 +08:00
Compare commits
7 Commits
73f8bbc36b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f17a5cc3d | ||
|
|
904dac1530 | ||
|
|
baa66bcf34 | ||
|
|
cdea0244a5 | ||
|
|
9ef7739c81 | ||
|
|
7cadca537e | ||
|
|
a7d4a73dd6 |
39
README.md
39
README.md
@@ -1,21 +1,26 @@
|
|||||||
<div align="center">
|
<div align="center" markdown="1">
|
||||||
<sup>Special thanks to:</sup>
|
<sup>Special thanks to:</sup>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<a href="https://tuple.app/vim-plug">
|
||||||
<a href="https://warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=vimplug_20240209">
|
<img alt="Tuple's sponsorship image" src="https://raw.githubusercontent.com/junegunn/i/master/tuple.png" width="400">
|
||||||
<div>
|
</a>
|
||||||
<img src="https://raw.githubusercontent.com/junegunn/i/master/warp.png" width="300" alt="Warp">
|
|
||||||
</div>
|
|
||||||
<b>Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.</b>
|
|
||||||
<div>
|
|
||||||
<sup>Visit warp.dev to learn more.</sup>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
<hr>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
|
### [Tuple, the premier screen sharing app for developers](https://tuple.app/vim-plug)
|
||||||
|
[Available for MacOS & Windows](https://tuple.app/vim-plug)<br>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<sup>Special thanks to:</sup>
|
||||||
|
<br>
|
||||||
|
<a href="https://www.warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=vim-plug">
|
||||||
|
<img alt="Warp sponsorship" width="400" src="https://github.com/user-attachments/assets/ab8dd143-b0fd-4904-bdc5-dd7ecac94eae">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
### [Warp, the intelligent terminal for developers](https://www.warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=vim-plug)
|
||||||
|
[Available for MacOS, Linux, & Windows](https://www.warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=vim-plug)<br>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
<h1 title="vim-plug">
|
<h1 title="vim-plug">
|
||||||
<picture>
|
<picture>
|
||||||
<source media="(prefers-color-scheme: dark)" srcset="./plug-dark.png">
|
<source media="(prefers-color-scheme: dark)" srcset="./plug-dark.png">
|
||||||
|
|||||||
52
plug.vim
52
plug.vim
@@ -372,8 +372,10 @@ 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 -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)',
|
\ has('patch-7.4.1898')
|
||||||
\ cmd, string(cmd), string(names))
|
\ ? 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, <q-mods> ,%s)'
|
||||||
|
\ : 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)'
|
||||||
|
\ , cmd, string(cmd), string(names))
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
for [map, names] in items(lod.map)
|
for [map, names] in items(lod.map)
|
||||||
@@ -651,11 +653,19 @@ function! s:lod_ft(pat, names)
|
|||||||
call s:doautocmd('filetypeindent', 'FileType')
|
call s:doautocmd('filetypeindent', 'FileType')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
if has('patch-7.4.1898')
|
||||||
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
function! s:lod_cmd(cmd, bang, l1, l2, args, mods, names)
|
||||||
call s:dobufread(a:names)
|
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
call s:dobufread(a:names)
|
||||||
endfunction
|
execute printf('%s %s%s%s %s', a:mods, (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
||||||
|
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
|
call s:dobufread(a:names)
|
||||||
|
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
|
|
||||||
function! s:lod_map(map, names, with_prefix, 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'])
|
||||||
@@ -1075,12 +1085,16 @@ function! s:hash_match(a, b)
|
|||||||
return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0
|
return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:disable_credential_helper()
|
||||||
|
return s:git_version_requirement(2) && get(g:, 'plug_disable_credential_helper', 1)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:checkout(spec)
|
function! s:checkout(spec)
|
||||||
let sha = a:spec.commit
|
let sha = a:spec.commit
|
||||||
let output = s:git_revision(a:spec.dir)
|
let output = s:git_revision(a:spec.dir)
|
||||||
let error = 0
|
let error = 0
|
||||||
if !empty(output) && !s:hash_match(sha, s:lines(output)[0])
|
if !empty(output) && !s:hash_match(sha, s:lines(output)[0])
|
||||||
let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : ''
|
let credential_helper = s:disable_credential_helper() ? '-c credential.helper= ' : ''
|
||||||
let output = s:system(
|
let output = s:system(
|
||||||
\ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
|
\ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
|
||||||
let error = v:shell_error
|
let error = v:shell_error
|
||||||
@@ -1589,7 +1603,7 @@ while 1 " Without TCO, Vim stack is bound to explode
|
|||||||
let [error, _] = s:git_validate(spec, 0)
|
let [error, _] = s:git_validate(spec, 0)
|
||||||
if empty(error)
|
if empty(error)
|
||||||
if pull
|
if pull
|
||||||
let cmd = s:git_version_requirement(2) ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch']
|
let cmd = s:disable_credential_helper() ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch']
|
||||||
if has_tag && !empty(globpath(spec.dir, '.git/shallow'))
|
if has_tag && !empty(globpath(spec.dir, '.git/shallow'))
|
||||||
call extend(cmd, ['--depth', '99999999'])
|
call extend(cmd, ['--depth', '99999999'])
|
||||||
endif
|
endif
|
||||||
@@ -2369,7 +2383,9 @@ function! s:git_validate(spec, check_branch)
|
|||||||
let err = join(['Invalid URI: '.remote,
|
let err = join(['Invalid URI: '.remote,
|
||||||
\ 'Expected: '.a:spec.uri,
|
\ 'Expected: '.a:spec.uri,
|
||||||
\ 'PlugClean required.'], "\n")
|
\ 'PlugClean required.'], "\n")
|
||||||
elseif a:check_branch && has_key(a:spec, 'commit')
|
elseif !a:check_branch
|
||||||
|
return ['', 0]
|
||||||
|
elseif has_key(a:spec, 'commit')
|
||||||
let sha = s:git_revision(a:spec.dir)
|
let sha = s:git_revision(a:spec.dir)
|
||||||
if empty(sha)
|
if empty(sha)
|
||||||
let err = join(add(result, 'PlugClean required.'), "\n")
|
let err = join(add(result, 'PlugClean required.'), "\n")
|
||||||
@@ -2378,18 +2394,16 @@ function! s:git_validate(spec, check_branch)
|
|||||||
\ a:spec.commit[:6], sha[:6]),
|
\ a:spec.commit[:6], sha[:6]),
|
||||||
\ 'PlugUpdate required.'], "\n")
|
\ 'PlugUpdate required.'], "\n")
|
||||||
endif
|
endif
|
||||||
|
elseif has_key(a:spec, 'tag')
|
||||||
|
let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir)
|
||||||
|
if a:spec.tag !=# tag && a:spec.tag !~ '\*'
|
||||||
|
let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.',
|
||||||
|
\ (empty(tag) ? 'N/A' : tag), a:spec.tag)
|
||||||
|
endif
|
||||||
elseif a:check_branch
|
elseif a:check_branch
|
||||||
let current_branch = result[0]
|
let current_branch = result[0]
|
||||||
" Check tag
|
|
||||||
let origin_branch = s:git_origin_branch(a:spec)
|
let origin_branch = s:git_origin_branch(a:spec)
|
||||||
if has_key(a:spec, 'tag')
|
if origin_branch !=# current_branch
|
||||||
let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir)
|
|
||||||
if a:spec.tag !=# tag && a:spec.tag !~ '\*'
|
|
||||||
let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.',
|
|
||||||
\ (empty(tag) ? 'N/A' : tag), a:spec.tag)
|
|
||||||
endif
|
|
||||||
" Check branch
|
|
||||||
elseif origin_branch !=# current_branch
|
|
||||||
let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.',
|
let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.',
|
||||||
\ current_branch, origin_branch)
|
\ current_branch, origin_branch)
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user