|
|
@ -1,21 +1,30 @@ |
|
|
|
|
|
func! vundle#config#init() |
|
|
|
|
|
if !exists('g:bundles') | let g:bundles = {} | endif |
|
|
|
|
|
call s:rtp_rm_a() |
|
|
|
|
|
let g:bundles = {} |
|
|
|
|
|
endf |
|
|
|
|
|
|
|
|
func! vundle#config#bundle(arg, ...) |
|
|
func! vundle#config#bundle(arg, ...) |
|
|
let opts = extend(s:parse_options(a:000), s:parse_name_spec(a:arg)) |
|
|
let opts = extend(s:parse_options(a:000), s:parse_name_spec(a:arg)) |
|
|
let bundle = vundle#config#init_bundle(opts.name,opts) |
|
|
let bundle = vundle#config#init_bundle(opts.name,opts) |
|
|
call s:rtp_rm_a() |
|
|
call s:rtp_rm_a() |
|
|
let g:bundles[bundle.name] = bundle |
|
|
|
|
|
|
|
|
let g:bundles[opts.name] = bundle |
|
|
call s:rtp_add_a() |
|
|
call s:rtp_add_a() |
|
|
return bundle |
|
|
return bundle |
|
|
endf |
|
|
endf |
|
|
|
|
|
|
|
|
func! vundle#config#init() |
|
|
|
|
|
if !exists('g:bundles') | let g:bundles = {} | endif |
|
|
|
|
|
call s:rtp_rm_a() |
|
|
|
|
|
let g:bundles = {} |
|
|
|
|
|
|
|
|
func! vundle#config#parse_name_spec(arg) |
|
|
|
|
|
return s:parse_name_spec(a:arg) |
|
|
endf |
|
|
endf |
|
|
|
|
|
|
|
|
func! vundle#config#require(bundles) abort |
|
|
func! vundle#config#require(bundles) abort |
|
|
for b in a:bundles |
|
|
|
|
|
call s:rtp_add(b.rtpath) |
|
|
|
|
|
|
|
|
if type(a:bundles) == type({}) |
|
|
|
|
|
let bundles = values(a:bundles) |
|
|
|
|
|
else |
|
|
|
|
|
let bundles = a:bundles |
|
|
|
|
|
endif |
|
|
|
|
|
for b in bundles |
|
|
|
|
|
call s:rtp_add(b.rtpath()) |
|
|
call s:rtp_add(g:bundle_dir) |
|
|
call s:rtp_add(g:bundle_dir) |
|
|
" TODO: it has to be relative rtpath, not bundle.name |
|
|
" TODO: it has to be relative rtpath, not bundle.name |
|
|
exec 'runtime! '.b.name.'/plugin/*.vim' |
|
|
exec 'runtime! '.b.name.'/plugin/*.vim' |
|
|
@ -27,16 +36,13 @@ endf |
|
|
func! vundle#config#init_bundle(name, opts) |
|
|
func! vundle#config#init_bundle(name, opts) |
|
|
let b = extend(a:opts, copy(s:bundle)) |
|
|
let b = extend(a:opts, copy(s:bundle)) |
|
|
let b.name = a:name |
|
|
let b.name = a:name |
|
|
if(has_key(b, "as")) |
|
|
|
|
|
let b.original_name = a:name |
|
|
|
|
|
let b.name = b.as |
|
|
|
|
|
endif |
|
|
|
|
|
let b.rtpath = s:rtpath(a:opts) |
|
|
|
|
|
|
|
|
"make sure keys for these options exist |
|
|
|
|
|
let b.name_spec = get(b, 'name_spec', a:name) |
|
|
|
|
|
let b.uri = get(b, 'uri', '') |
|
|
return b |
|
|
return b |
|
|
endf |
|
|
endf |
|
|
|
|
|
|
|
|
func! s:parse_options(opts) |
|
|
func! s:parse_options(opts) |
|
|
" TODO: improve this |
|
|
|
|
|
if len(a:opts) < 1 | return {} | endif |
|
|
if len(a:opts) < 1 | return {} | endif |
|
|
|
|
|
|
|
|
if type(a:opts[0]) == type({}) |
|
|
if type(a:opts[0]) == type({}) |
|
|
@ -53,6 +59,13 @@ func! s:parse_name_spec(arg) |
|
|
let arg = substitute(a:arg,"['".'"]\+','','g') |
|
|
let arg = substitute(a:arg,"['".'"]\+','','g') |
|
|
let git_proto = exists('g:vundle_default_git_proto') ? g:vundle_default_git_proto : 'https' |
|
|
let git_proto = exists('g:vundle_default_git_proto') ? g:vundle_default_git_proto : 'https' |
|
|
|
|
|
|
|
|
|
|
|
let altname = '' |
|
|
|
|
|
let name_spec = arg |
|
|
|
|
|
if arg =~? ' as ' |
|
|
|
|
|
let altname = split(arg, ' as ')[-1] |
|
|
|
|
|
let arg = split(arg, ' as ')[0] |
|
|
|
|
|
endif |
|
|
|
|
|
|
|
|
if arg =~? '^\s*\(gh\|github\):\S\+' |
|
|
if arg =~? '^\s*\(gh\|github\):\S\+' |
|
|
\ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$' |
|
|
\ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$' |
|
|
let uri = git_proto.'://github.com/'.split(arg, ':')[-1] |
|
|
let uri = git_proto.'://github.com/'.split(arg, ':')[-1] |
|
|
@ -69,23 +82,15 @@ func! s:parse_name_spec(arg) |
|
|
let name = arg |
|
|
let name = arg |
|
|
let uri = git_proto.'://github.com/vim-scripts/'.name.'.git' |
|
|
let uri = git_proto.'://github.com/vim-scripts/'.name.'.git' |
|
|
endif |
|
|
endif |
|
|
return {'name': name, 'uri': uri, 'name_spec': arg } |
|
|
|
|
|
|
|
|
return {'name': empty(altname) ? name : altname, 'uri': uri, 'name_spec': name_spec } |
|
|
endf |
|
|
endf |
|
|
|
|
|
|
|
|
func! s:rtp_rm_a() |
|
|
func! s:rtp_rm_a() |
|
|
let paths = map(copy(g:bundles), 'v:val.rtpath') |
|
|
|
|
|
let prepends = join(values(paths), ',') |
|
|
|
|
|
let appends = join(values(paths), '/after,').'/after' |
|
|
|
|
|
exec 'set rtp-='.fnameescape(prepends) |
|
|
|
|
|
exec 'set rtp-='.fnameescape(appends) |
|
|
|
|
|
|
|
|
call filter(values(g:bundles), 's:rtp_rm(v:val.rtpath())') |
|
|
endf |
|
|
endf |
|
|
|
|
|
|
|
|
func! s:rtp_add_a() |
|
|
func! s:rtp_add_a() |
|
|
let paths = map(copy(g:bundles), 'v:val.rtpath') |
|
|
|
|
|
let prepends = join(values(paths), ',') |
|
|
|
|
|
let appends = join(values(paths), '/after,').'/after' |
|
|
|
|
|
exec 'set rtp^='.fnameescape(prepends) |
|
|
|
|
|
exec 'set rtp+='.fnameescape(appends) |
|
|
|
|
|
|
|
|
call filter(reverse(values(g:bundles)), 's:rtp_add(v:val.rtpath())') |
|
|
endf |
|
|
endf |
|
|
|
|
|
|
|
|
func! s:rtp_rm(dir) abort |
|
|
func! s:rtp_rm(dir) abort |
|
|
@ -102,13 +107,12 @@ func! s:expand_path(path) abort |
|
|
return simplify(expand(a:path, 1)) |
|
|
return simplify(expand(a:path, 1)) |
|
|
endf |
|
|
endf |
|
|
|
|
|
|
|
|
func! s:rtpath(opts) |
|
|
|
|
|
return has_key(a:opts, 'rtp') ? s:expand_path(a:opts.path().'/'.a:opts.rtp) : a:opts.path() |
|
|
|
|
|
endf |
|
|
|
|
|
|
|
|
|
|
|
let s:bundle = {'local': 0} |
|
|
|
|
|
|
|
|
let s:bundle = {} |
|
|
|
|
|
|
|
|
func! s:bundle.path() |
|
|
func! s:bundle.path() |
|
|
return s:expand_path(g:bundle_dir.'/'.self.name) |
|
|
return s:expand_path(g:bundle_dir.'/'.self.name) |
|
|
endf |
|
|
endf |
|
|
|
|
|
|
|
|
|
|
|
func! s:bundle.rtpath() |
|
|
|
|
|
return has_key(self, 'rtp') ? s:expand_path(self.path().'/'.self.rtp) : self.path() |
|
|
|
|
|
endf |