Browse Source

refactored config for git tree-ish support

pull/189/head
Aleksey 'Xerkus' Khudyakov 14 years ago
parent
commit
9dc04b37c6
1 changed files with 25 additions and 17 deletions
  1. +25
    -17
      autoload/vundle/config.vim

+ 25
- 17
autoload/vundle/config.vim View File

@ -1,15 +1,16 @@
func! vundle#config#bundle(arg, ...)
let bundle = vundle#config#init_bundle(a:arg, a:000)
let opts = extend(s:parse_options(a:000), s:parse_name_spec(a:arg))
let bundle = vundle#config#init_bundle(opts.name,opts)
call s:rtp_rm_a()
call add(g:bundles, bundle)
let g:bundles[bundle.name] = bundle
call s:rtp_add_a()
return bundle
endf
func! vundle#config#init()
if !exists('g:bundles') | let g:bundles = [] | endif
if !exists('g:bundles') | let g:bundles = {} | endif
call s:rtp_rm_a()
let g:bundles = []
let g:bundles = {}
endf
func! vundle#config#require(bundles) abort
@ -24,25 +25,32 @@ func! vundle#config#require(bundles) abort
endf
func! vundle#config#init_bundle(name, opts)
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')))
let b = extend(opts, copy(s:bundle))
let b.rtpath = s:rtpath(opts)
let b = extend(a:opts, copy(s:bundle))
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)
return b
endf
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({})
return a:opts[0]
else
return {'rev': a:opts[0]}
endif
let opts = {'tree-ish': a:opts[0]}
if len(a:opts) >= 2 && type(a:opts[1]) == type({})
let opts = extend(a:opts[1], opts)
endif
return opts
endf
func! s:parse_name(arg)
let arg = a:arg
func! s:parse_name_spec(arg)
let arg = substitute(a:arg,"['".'"]\+','','g')
let git_proto = exists('g:vundle_default_git_proto') ? g:vundle_default_git_proto : 'https'
if arg =~? '^\s*\(gh\|github\):\S\+'
@ -66,16 +74,16 @@ endf
func! s:rtp_rm_a()
let paths = map(copy(g:bundles), 'v:val.rtpath')
let prepends = join(paths, ',')
let appends = join(paths, '/after,').'/after'
let prepends = join(values(paths), ',')
let appends = join(values(paths), '/after,').'/after'
exec 'set rtp-='.fnameescape(prepends)
exec 'set rtp-='.fnameescape(appends)
endf
func! s:rtp_add_a()
let paths = map(copy(g:bundles), 'v:val.rtpath')
let prepends = join(paths, ',')
let appends = join(paths, '/after,').'/after'
let prepends = join(values(paths), ',')
let appends = join(values(paths), '/after,').'/after'
exec 'set rtp^='.fnameescape(prepends)
exec 'set rtp+='.fnameescape(appends)
endf
@ -98,7 +106,7 @@ 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 = {}
let s:bundle = {'local': 0}
func! s:bundle.path()
return s:expand_path(g:bundle_dir.'/'.self.name)


Loading…
Cancel
Save