" Add a plugin to the runtimepath. " " arg -- a string specifying the plugin " ... -- a dictionary of options for the plugin " return -- the return value from vundle#config#init_bundle() func! vundle#config#bundle(arg, ...) let bundle = vundle#config#init_bundle(a:arg, a:000) if exists('g:vundle_lazy_load') && g:vundle_lazy_load call add(g:bundles, bundle) else call s:rtp_rm_a() call add(g:bundles, bundle) call s:rtp_add_a() call s:rtp_add_defaults() endif return bundle endf func! vundle#config#activate_bundles() call s:rtp_add_a() call s:rtp_add_defaults() endf " Initialize Vundle. " " return -- 0 (unconditionally) func! vundle#config#init() if !exists('g:bundles') | let g:bundles = [] | endif call s:rtp_rm_a() let g:bundles = [] endf " Add a list of bundles to the runtimepath and source them. " " bundles -- a list of bundle objects " return -- 0 (unconditionally) func! vundle#config#require(bundles) abort for b in a:bundles call s:rtp_add(b.rtpath) call s:rtp_add(g:bundle_dir) " TODO: it has to be relative rtpath, not bundle.name exec 'runtime! '.b.name.'/plugin/*.vim' exec 'runtime! '.b.name.'/after/*.vim' call s:rtp_rm(g:bundle_dir) endfor call s:rtp_add_defaults() endf " Create a bundle object from a bundle specification. " " name -- the bundle specification as a string " opts -- the options dictionary from then bundle definition " return -- an initialized bundle object func! vundle#config#init_bundle(name, opts) if a:name != substitute(a:name, '^\s*\(.\{-}\)\s*$', '\1', '') echo "Spurious leading and/or trailing whitespace found in plugin spec '" . a:name . "'" endif let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')), 'keep') let b = extend(opts, copy(s:bundle)) let b.rtpath = s:rtpath(opts) return b endf " Parse the options which can be supplied with the bundle specification. " Corresponding documentation: vundle-plugins-configure " " opts -- a dictionary with the user supplied options for the bundle " return -- a dictionary with the user supplied options for the bundle, this " will be merged with a s:bundle object into one dictionary. func! s:parse_options(opts) " TODO: improve this if len(a:opts) != 1 | return {} | endif if type(a:opts[0]) == type({}) return a:opts[0] else return {'rev': a:opts[0]} endif endf " Parse the plugin specification. Corresponding documentation: " vundle-plugins-uris " " arg -- the string supplied to identify the plugin " return -- a dictionary with the folder name (key 'name') and the uri (key " 'uri') for cloning the plugin and the original argument (key " 'name_spec') func! s:parse_name(arg) let arg = a:arg let git_proto = exists('g:vundle_default_git_proto') ? g:vundle_default_git_proto : 'https' if arg =~? '^\s*\(gh\|github\):\S\+' \ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$' let uri = git_proto.'://github.com/'.split(arg, ':')[-1] if uri !~? '\.git$' let uri .= '.git' endif let name = substitute(split(uri,'\/')[-1], '\.git\s*$','','i') elseif arg =~? '^\s*\(git@\|git://\)\S\+' \ || arg =~? '\(file\|https\?\)://' \ || arg =~? '\.git\s*$' let uri = arg let name = split( substitute(uri,'/\?\.git\s*$','','i') ,'\/')[-1] else let name = arg let uri = git_proto.'://github.com/vim-scripts/'.name.'.git' endif return {'name': name, 'uri': uri, 'name_spec': arg } endf func! s:rtp_add_defaults() let current = &rtp set rtp&vim let default = &rtp let &rtp = current for item in reverse(split(default, ',')) exec 'set rtp-=' . item if fnamemodify(item, ":t") == 'after' exec 'set rtp+=' . item else exec 'set rtp^=' . item endif endfor endf " Remove all paths for the plugins which are managed by Vundle from the " runtimepath. " " return -- 0 (unconditionally) func! s:rtp_rm_a() let paths = map(copy(g:bundles), 'v:val.rtpath') let prepends = join(paths, ',') let appends = join(paths, '/after,').'/after' exec 'set rtp-='.fnameescape(prepends) exec 'set rtp-='.fnameescape(appends) endf " Add all paths for the plugins which are managed by Vundle to the " runtimepath. " " return -- 0 (unconditionally) func! s:rtp_add_a() let paths = map(copy(g:bundles), 'v:val.rtpath') let prepends = join(paths, ',') let appends = join(paths, '/after,').'/after' exec 'set rtp^='.fnameescape(prepends) exec 'set rtp+='.fnameescape(appends) endf " Remove a directory and the corresponding 'after' directory from runtimepath. " " dir -- the directory name to be removed as a string. The corresponding " 'after' directory will also be removed. " return -- 0 (unconditionally) func! s:rtp_rm(dir) abort exec 'set rtp-='.fnameescape(expand(a:dir, 1)) exec 'set rtp-='.fnameescape(expand(a:dir.'/after', 1)) endf " Add a directory and the corresponding 'after' directory to runtimepath. " " dir -- the directory name to be added as a string. The corresponding " 'after' directory will also be added. " return -- 0 (unconditionally) func! s:rtp_add(dir) abort exec 'set rtp^='.fnameescape(expand(a:dir, 1)) exec 'set rtp+='.fnameescape(expand(a:dir.'/after', 1)) endf " Expand and simplify a path. " " path -- the path to expand as a string " return -- the expanded and simplified path func! s:expand_path(path) abort return simplify(expand(a:path, 1)) endf " Find the actual path inside a bundle directory to be added to the " runtimepath. It might be provided by the user with the 'rtp' option. " Corresponding documentation: vundle-plugins-configure " " opts -- a bundle dict " return -- expanded path to the corresponding plugin directory func! s:rtpath(opts) return has_key(a:opts, 'rtp') ? s:expand_path(a:opts.path().'/'.a:opts.rtp) : a:opts.path() endf " a bundle 'object' let s:bundle = {} " FIXME: This function is only called once and in most cases the return value " is stored in the bundle object as obj.rtpath unmodfied. Is this necessary? " " Return the absolute path to the directory inside the bundle directory " (prefix) where thr bundle will be cloned. " " return -- the target location to clone this bundle to func! s:bundle.path() return s:expand_path(g:bundle_dir.'/'.self.name) endf func! s:bundle.is_pinned() return get(self, 'pinned') endf