mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-23 20:45:31 -07:00
Minor refactoring
This commit is contained in:
parent
42a42e7e71
commit
9ceb9caa09
47
plug.vim
47
plug.vim
@ -179,14 +179,33 @@ function! plug#end()
|
|||||||
syntax on
|
syntax on
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
if s:is_win
|
||||||
function! s:rtp(spec)
|
function! s:rtp(spec)
|
||||||
let rtp = s:dirpath(a:spec.dir . get(a:spec, 'rtp', ''))
|
let rtp = s:dirpath(a:spec.dir . get(a:spec, 'rtp', ''))
|
||||||
if s:is_win
|
return substitute(rtp, '\\*$', '', '')
|
||||||
let rtp = substitute(rtp, '\\*$', '', '')
|
|
||||||
endif
|
|
||||||
return rtp
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:path(path)
|
||||||
|
return substitute(substitute(a:path, '/', '\', 'g'), '[/\\]*$', '', '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:dirpath(path)
|
||||||
|
return s:path(a:path) . '\'
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:rtp(spec)
|
||||||
|
return s:dirpath(a:spec.dir . get(a:spec, 'rtp', ''))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:path(path)
|
||||||
|
return substitute(a:path, '[/\\]*$', '', '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:dirpath(path)
|
||||||
|
return s:path(a:path) . '/'
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
|
|
||||||
function! s:esc(path)
|
function! s:esc(path)
|
||||||
return substitute(a:path, ' ', '\\ ', 'g')
|
return substitute(a:path, ' ', '\\ ', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
@ -258,6 +277,9 @@ function! s:add(...)
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let name = substitute(split(plugin, '/')[-1], '\.git$', '', '')
|
||||||
|
if !force && has_key(g:plugs, name) | return | endif
|
||||||
|
|
||||||
if plugin =~ ':'
|
if plugin =~ ':'
|
||||||
let uri = plugin
|
let uri = plugin
|
||||||
else
|
else
|
||||||
@ -267,9 +289,6 @@ function! s:add(...)
|
|||||||
let uri = 'https://git:@github.com/' . plugin . '.git'
|
let uri = 'https://git:@github.com/' . plugin . '.git'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let name = substitute(split(plugin, '/')[-1], '\.git$', '', '')
|
|
||||||
if !force && has_key(g:plugs, name) | return | endif
|
|
||||||
|
|
||||||
let dir = s:dirpath( fnamemodify(join([g:plug_home, name], '/'), ':p') )
|
let dir = s:dirpath( fnamemodify(join([g:plug_home, name], '/'), ':p') )
|
||||||
let spec = extend(opts, { 'dir': dir, 'uri': uri })
|
let spec = extend(opts, { 'dir': dir, 'uri': uri })
|
||||||
let g:plugs[name] = spec
|
let g:plugs[name] = spec
|
||||||
@ -648,20 +667,6 @@ function! s:update_parallel(pull, todo, threads)
|
|||||||
EOF
|
EOF
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:path(path)
|
|
||||||
return substitute(s:is_win ? substitute(a:path, '/', '\', 'g') : a:path,
|
|
||||||
\ '[/\\]*$', '', '')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:dirpath(path)
|
|
||||||
let path = s:path(a:path)
|
|
||||||
if s:is_win
|
|
||||||
return path !~ '\\$' ? path.'\' : path
|
|
||||||
else
|
|
||||||
return path !~ '/$' ? path.'/' : path
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:shellesc(arg)
|
function! s:shellesc(arg)
|
||||||
return '"'.substitute(a:arg, '"', '\\"', 'g').'"'
|
return '"'.substitute(a:arg, '"', '\\"', 'g').'"'
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user