Skip to content

Commit

Permalink
Add comments to document the code
Browse files Browse the repository at this point in the history
Also add some FIXME markers in places where the code needs more
explanation.
  • Loading branch information
lucc authored and jdevera committed Apr 10, 2014
1 parent f3da687 commit b3b5f52
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 13 deletions.
25 changes: 15 additions & 10 deletions autoload/vundle.vim
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ com! -nargs=? -bang VundleClean Plugi
com! -nargs=0 VundleDocs PluginDocs
com! VundleUpdate PluginInstall!

" deprecated
" Deprecated Commands
com! -nargs=+ Bundle call vundle#config#bundle(<args>)
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall PluginInstall<bang> <args>
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleSearch PluginSearch<bang> <args>
Expand All @@ -46,18 +46,23 @@ com! -nargs=? -bang BundleClean Plugi
com! -nargs=0 BundleDocs PluginDocs
com! BundleUpdate PluginInstall!

" Set up the signs used in the installer window. (See :help signs)
if (has('signs'))
sign define Vu_error text=! texthl=Error
sign define Vu_active text=> texthl=Comment
sign define Vu_todate text=. texthl=Comment
sign define Vu_new text=+ texthl=Comment
sign define Vu_updated text=* texthl=Comment
sign define Vu_deleted text=- texthl=Comment
sign define Vu_helptags text=* texthl=Comment
sign define Vu_pinned text== texthl=Comment
sign define Vu_error text=! texthl=Error
sign define Vu_active text=> texthl=Comment
sign define Vu_todate text=. texthl=Comment
sign define Vu_new text=+ texthl=Comment
sign define Vu_updated text=* texthl=Comment
sign define Vu_deleted text=- texthl=Comment
sign define Vu_helptags text=* texthl=Comment
sign define Vu_pinned text== texthl=Comment
endif


" Set up Vundle. This function has to be called from the users vimrc file.
" This will force Vim to source this file as a side effect which wil define
" the :Plugin command. After calling this function the user can use the
" :Plugin command in the vimrc. It is not possible to do this automatically
" because when loading the vimrc file no plugins where loaded yet.
func! vundle#rc(...) abort
let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1)
let g:updated_bundles = []
Expand Down
66 changes: 66 additions & 0 deletions autoload/vundle/config.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
" 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
Expand All @@ -16,12 +21,19 @@ func! vundle#config#activate_bundles()
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)
Expand All @@ -34,6 +46,11 @@ func! vundle#config#require(bundles) abort
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 . "'"
Expand All @@ -44,6 +61,12 @@ func! vundle#config#init_bundle(name, 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
Expand All @@ -55,6 +78,13 @@ func! s:parse_options(opts)
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'
Expand Down Expand Up @@ -94,6 +124,10 @@ func! s:rtp_add_defaults()
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, ',')
Expand All @@ -102,6 +136,10 @@ func! s:rtp_rm_a()
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, ',')
Expand All @@ -110,26 +148,54 @@ func! s:rtp_add_a()
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
Expand Down
Loading

0 comments on commit b3b5f52

Please sign in to comment.