Compare commits

...

56 Commits

Author SHA1 Message Date
  gmarik 1df405ed65 Merging master 13 years ago
  gmarik 2275bf6792 use local variable 13 years ago
  gmarik 95d56c5763 comment out echoing 13 years ago
  gmarik a2e14b4202 Merge remote branch 'origin/events' into events 13 years ago
  gmarik f4ce72fdb0 fix indent 13 years ago
  gmarik 67d07c9797 Merge remote branch 'origin/master' into events 13 years ago
  gmarik 67da50189d source after/ dir aswell 13 years ago
  gmarik 9291b006bf after downloading plugin require ./bundle/plugin_name.vim 13 years ago
  gmarik 288a8b0f85 extract s:source function 13 years ago
  gmarik e835cf1e05 rename require to source 13 years ago
  gmarik 52456534f9 replace runtime! calls with source 13 years ago
  gmarik 436ad21cfe Docs 13 years ago
  gmarik 3c765673db Docs 13 years ago
  gmarik a1e6736ced prepend git branch name to test bundle_dir 13 years ago
  gmarik 7aa574165c Vundle is a bundle too! 13 years ago
  gmarik fa93510c55 expand path 13 years ago
  gmarik 8cb63f0b1a hint 13 years ago
  gmarik c3ecda56b1 reset only on update 13 years ago
  gmarik c62d68f1b9 add 'CSS-Higlights' 13 years ago
  gmarik 77a53dac78 invoke BundleInstallPre before actually installing 13 years ago
  gmarik bf2d518ea5 add user# scoped autogroup 13 years ago
  gmarik e45bb42b49 downcase 13 years ago
  gmarik 3df2fb7d9f add TODO 13 years ago
  gmarik e95a749e2c autocomplete with configured bundle names too 13 years ago
  gmarik 415a44d0f8 try to find configured bundle first 13 years ago
  gmarik bfbac3c9b8 fix invalid merge 13 years ago
  gmarik f4a15996cf Merge branch 'nosync' into events 13 years ago
  gmarik 258dd4cf5d comment 13 years ago
  gmarik be9a50dfe2 tests 13 years ago
  gmarik 9a0d37beb8 let options override name/uri 13 years ago
  gmarik 625a110af4 moar tests 13 years ago
  gmarik 073ddf6965 with nosync consider bundles installed too 13 years ago
  gmarik f5a079deae with nosync use existing dir as a DESTINATION path too 13 years ago
  gmarik 658be0b24c consider existing directory a valid uri too 13 years ago
  gmarik 25a1d708bd do not clean/install automatically 13 years ago
  gmarik 114779700e tests 13 years ago
  gmarik c0556355d2 simplify 13 years ago
  gmarik a42550779a use uri as path when nosync is set 13 years ago
  gmarik efec93b0a9 Bundle! (with bang) adds {'sync':'no'} 13 years ago
  gmarik ece8fdccbf use bundle.installed to check installation 13 years ago
  gmarik b32ac42e06 check whether bundle installed 13 years ago
  gmarik 58ae807ead evented approach 13 years ago
  gmarik 4c9ee90991 check whether bundle installed 13 years ago
  gmarik 60a46cd58e do not sync when `sync` is set to `no` 13 years ago
  gmarik 124c5abb85 test plugin 13 years ago
  gmarik 9269d818f4 support sync:no option 13 years ago
  gmarik b133de8d93 rename vundle global variables 13 years ago
  gmarik ab71d33a53 rename vundle global variables 13 years ago
  gmarik 15027f3348 simplify 13 years ago
  gmarik d4eb8c3545 Rename Event according to Vim conventions 13 years ago
  gmarik affcdbbee4 add command-t to test autogroup hooks 13 years ago
  gmarik 87912d06a3 remove commands from test/vimrc 13 years ago
  gmarik b7ac31ff32 verify existing augroup names before executing 13 years ago
  gmarik 06f1ec36f8 simplify 13 years ago
  gmarik 8a2de7543b augroup name should be lowercase 13 years ago
  gmarik e8a851b164 initial event-like interface 13 years ago
7 changed files with 225 additions and 62 deletions
Split View
  1. +2
    -0
      README.md
  2. +26
    -4
      autoload/vundle.vim
  3. +56
    -23
      autoload/vundle/config.vim
  4. +68
    -19
      autoload/vundle/installer.vim
  5. +3
    -1
      autoload/vundle/scripts.vim
  6. +3
    -0
      test/plugin/test_plugin.vim
  7. +67
    -15
      test/vimrc

+ 2
- 0
README.md View File

@ -6,6 +6,7 @@
1. Setup [Vundle]:
```
$ git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
```
@ -43,6 +44,7 @@
" filetype plugin on " to not use the indentation settings set by plugins
```
3. Install configured bundles:
Launch `vim`, run `:BundleInstall`.


+ 26
- 4
autoload/vundle.vim View File

@ -4,8 +4,8 @@
" Readme: http://github.com/gmarik/vundle/blob/master/README.md
" Version: 0.8
com! -nargs=+ Bundle
\ call vundle#config#bundle(<args>)
com! -nargs=+ -bang Bundle
\ call vundle#config#bundle('!' == '<bang>', <args>)
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall
\ call vundle#installer#install('!' == '<bang>', <q-args>)
@ -17,7 +17,7 @@ com! -nargs=? -bang BundleClean
\ call vundle#installer#clean('!' == '<bang>')
com! -nargs=0 BundleDocs
\ call vundle#installer#helptags(g:bundles)
\ call vundle#installer#helptags(g:vundle#bundles)
" deprecated in favor of Bundles
com! -nargs=? -bang BundleSearch
@ -29,6 +29,28 @@ au Syntax vim syn keyword vimCommand Bundle
func! vundle#rc(...) abort
let g:bundle_dir = len(a:000) > 0 ? expand(a:1) : expand('$HOME/.vim/bundle')
let g:vundle#bundle_dir = len(a:000) > 0 ? expand(a:1) : expand('$HOME/.vim/bundle')
call vundle#config#init()
endf
augroup bundle#command-t
au!
au User BundleInstallPost echo 'Running command-t hooks'
au User BundleInstallPost !cd ruby/command-t && ruby extconf.rb && make clean && make
au User BundleInstallPost ![ -f doc/readme.txt -a -f doc/command-t.txt ] && rm doc/README.txt
au User BundleInstallPost echohl WarningMsg | echo 'Please restart Vim for command-t to work' | echohl None
augroup end
augroup vundle#bundle
au!
au User BundleInstallPre echo 'Installing '.g:bundle.name
au User BundleInstall call vundle#installer#sync(1, g:bundle)
au User BundleInstall call vundle#config#configure(g:bundle)
au User BundleInstallPost echo 'Installed '.g:bundle.name
au User BundleInstalled echo 'Already Installed '.g:bundle.name
au User BundlesInstallPost call vundle#config#source(g:bundles)
au User BundlesInstallPost call vundle#installer#helptags(g:bundles)
au User BundlesInstallPost echo len(g:bundles).' '. "bundles installed"
augroup end

+ 56
- 23
autoload/vundle/config.vim View File

@ -1,41 +1,59 @@
func! vundle#config#bundle(arg, ...)
let bundle = vundle#config#init_bundle(a:arg, a:000)
func! vundle#config#bundle(bang, arg, ...) abort
let bundle = vundle#config#init_bundle(a:bang, a:arg, a:000)
call s:rtp_rm_a()
call add(g:bundles, bundle)
call add(g:vundle#bundles, bundle)
call s:rtp_add_a()
endf
func! vundle#config#init()
if !exists('g:bundles') | let g:bundles = [] | endif
if !exists('g:vundle#bundles') | let g:vundle#bundles = [] | endif
call s:rtp_rm_a()
let g:bundles = []
let g:vundle#bundles = []
endf
func! vundle#config#require(bundles) abort
func! vundle#config#configure(bundle) abort
return s:source(a:bundle.rtpath().'/bundle/'.a:bundle.name.'.vim')
endf
func! vundle#config#source(bundles) abort
for b in a:bundles
" TODO: should this be here?
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)
" load plugin
call s:source(b.rtpath().'/plugin/**/*.vim')
call s:source(b.rtpath().'/after/**/*.vim')
endfor
endf
func! s:source(glob) abort
for s in s:glob(a:glob)
exec 'source '.s
endfor
endf
func! vundle#config#init_bundle(name, opts)
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')))
func! s:glob(pattern)
return split(glob(a:pattern),"\n")
endf
func! vundle#config#init_bundle(bang, name, opts)
let opts = extend(s:parse_options(a:bang, a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')),'keep')
return extend(opts, copy(s:bundle))
endf
func! s:parse_options(opts)
" TODO: improve this
if len(a:opts) != 1 | return {} | endif
func! s:parse_options(bang, opts)
if len(a:opts) != 1
let opts = {}
elseif type(a:opts[0]) == type({})
let opts = a:opts[0]
elseif type(a:opts[0]) == type('')
let opts = {'rev': a:opts[0]}
endif
if type(a:opts[0]) == type({})
return a:opts[0]
else
return {'rev': a:opts[0]}
if a:bang
let opts = extend({'sync':'no'}, opts)
endif
return opts
endf
func! s:parse_name(arg)
@ -47,6 +65,7 @@ func! s:parse_name(arg)
elseif arg =~? '^\s*\(git@\|git://\)\S\+'
\ || arg =~? '\(file\|https\?\)://'
\ || arg =~? '\.git\s*$'
\ || isdirectory(expand(arg))
let uri = arg
let name = split( substitute(uri,'/\?\.git\s*$','','i') ,'\/')[-1]
else
@ -57,11 +76,11 @@ func! s:parse_name(arg)
endf
func! s:rtp_rm_a()
call filter(copy(g:bundles), 's:rtp_rm(v:val.rtpath())')
call filter(copy(g:vundle#bundles), 's:rtp_rm(v:val.rtpath())')
endf
func! s:rtp_add_a()
call filter(reverse(copy(g:bundles)), 's:rtp_add(v:val.rtpath())')
call filter(reverse(copy(g:vundle#bundles)), 's:rtp_add(v:val.rtpath())')
endf
func! s:rtp_rm(dir) abort
@ -80,8 +99,22 @@ endf
let s:bundle = {}
func! s:bundle.nosync()
return has_key(self, 'sync') && 'no' == self.sync
endf
func! s:bundle.installed()
return !empty(split(globpath(self.path(), '*'), "\n"))
endf
func! s:bundle.path()
return s:expand_path(g:bundle_dir.'/'.self.name)
" TODO: should lcd to tmpdir here
" TODO: FIX this spagetti
if self.nosync() && isdirectory(expand(self.uri))
return s:expand_path(self.uri)
endif
return s:expand_path(g:vundle#bundle_dir.'/'.self.name)
endf
func! s:bundle.rtpath()


+ 68
- 19
autoload/vundle/installer.vim View File

@ -1,19 +1,63 @@
func! vundle#installer#install(bang, ...) abort
if !isdirectory(g:bundle_dir) | call mkdir(g:bundle_dir, 'p') | endif
if !isdirectory(g:vundle#bundle_dir) | call mkdir(g:vundle#bundle_dir, 'p') | endif
let bundles = (a:1 == '') ?
\ s:reload_bundles() :
\ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})')
\ [s:find_or_init_by_name(a:1)]
let installed = s:install(a:bang, bundles)
redraw!
" TODO: handle error: let user know hen they need to restart Vim
call vundle#config#require(bundles)
let cwd = getcwd()
let new_bundles = []
call s:log("Installed bundles:\n".join((empty(installed) ?
\ ['no new bundles installed'] :
\ map(installed, 'v:val.name')),"\n"))
for bundle in bundles
if !isdirectory(bundle.path()) | call mkdir(bundle.path(), 'p') | endif
call vundle#installer#helptags(bundles)
let [name, g:bundle] = [tolower(bundle.name) ,bundle]
lcd `=bundle.path()`
if a:bang || !(bundle.installed())
call s:doautocmd('BundleInstallPre' ,'vundle#bundle')
call s:doautocmd('BundleInstallPre' ,'bundle#'.name)
call s:doautocmd('BundleInstallPre' ,'user#'.name)
call s:doautocmd('BundleInstall' ,'vundle#bundle')
call s:doautocmd('BundleInstall' ,'bundle#'.name)
call s:doautocmd('BundleInstall' ,'user#'.name)
call s:doautocmd('BundleInstallPost' ,'vundle#bundle')
call s:doautocmd('BundleInstallPost' ,'bundle#'.name)
call s:doautocmd('BundleInstallPost' ,'user#'.name)
call add(new_bundles, bundle)
else
call s:doautocmd('BundleInstalled' ,'vundle#bundle')
call s:doautocmd('BundleInstalled' ,'bundle#'.name)
call s:doautocmd('BundleInstalled' ,'user#'.name)
endif
lcd `=cwd`
endfor
let g:bundles = new_bundles
call s:doautocmd('BundlesInstallPost', 'vundle#bundle')
call s:doautocmd('BundlesInstallPost', 'user#bundle')
endf
" TODO: improve this
" TODO: init_bundle should happen first though to get proper bundle name
func! s:find_or_init_by_name(name)
let matches = filter(copy(g:vundle#bundles), 'v:val.name == a:name')
if (!empty(matches))
return matches[0] "assuming only 1 match may happen
endif
return vundle#config#init_bundle(0, a:name, {})
endf
" TODO: verify whether autocommand already exists
" verbose autocmd User BundleInstall*
func! s:doautocmd(event, augroup_name)
if 0 <= index(s:load_augroups(), a:augroup_name)
exec 'doautocmd '.a:augroup_name.' User '.a:event
endif
endf
func! vundle#installer#helptags(bundles) abort
@ -27,8 +71,8 @@ func! vundle#installer#helptags(bundles) abort
endf
func! vundle#installer#clean(bang) abort
let bundle_dirs = map(copy(g:bundles), 'v:val.path()')
let all_dirs = split(globpath(g:bundle_dir, '*'), "\n")
let bundle_dirs = map(copy(g:vundle#bundles), 'v:val.path()')
let all_dirs = split(globpath(g:vundle#bundle_dir, '*'), "\n")
let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
if empty(x_dirs)
@ -48,7 +92,7 @@ func! s:reload_bundles()
" TODO: obtain Bundles without sourcing .vimrc
if filereadable($MYVIMRC)| silent source $MYVIMRC | endif
if filereadable($MYGVIMRC)| silent source $MYGVIMRC | endif
return g:bundles
return g:vundle#bundles
endf
func! s:has_doc(rtp) abort
@ -65,9 +109,9 @@ func! s:helptags(rtp) abort
endtry
endf
func! s:sync(bang, bundle) abort
let git_dir = expand(a:bundle.path().'/.git/')
if isdirectory(git_dir)
func! vundle#installer#sync(bang, bundle) abort
if a:bundle.nosync() | return a:bang | endif
if a:bundle.installed()
if !(a:bang) | return 0 | endif
let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull'
@ -78,12 +122,17 @@ func! s:sync(bang, bundle) abort
else
let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
endif
silent exec '!'.cmd
" exec '!echo '.shellescape(cmd)
silent exec '!'.cmd
return 1
endf
func! s:install(bang, bundles) abort
return filter(copy(a:bundles), 's:sync(a:bang, v:val)')
func! s:load_augroups()
redir => v | silent verbose augroup | redir END
let augroups = map(split(v,'[\n\r\t\ ]\+'), 'tolower(v:val)')
return augroups
endf
" TODO: make it pause after output in console mode


+ 3
- 1
autoload/vundle/scripts.vim View File

@ -21,7 +21,9 @@ func! vundle#scripts#reload() abort
endf
func! vundle#scripts#complete(a,c,d)
return join(s:load_scripts(0),"\n")
let configured = map(copy(g:vundle#bundles), 'v:val.name')
let vim_scripts = s:load_scripts(0)
return join(configured + vim_scripts,"\n")
endf
func! vundle#scripts#install() abort


+ 3
- 0
test/plugin/test_plugin.vim View File

@ -0,0 +1,3 @@
func! g:vundle_test_plugin()
return 'ok'
endf

+ 67
- 15
test/vimrc View File

@ -1,24 +1,27 @@
" vim -u test/vimrc
" vim -gu test/vimrc
set nocompatible
let root = '/tmp/vundle_bundles/'
let src = 'http://github.com/gmarik/vundle.git'
" let src = '~/.vim/bundle/vundle/.git'
syntax on
silent exec 'e '.expand('<sfile>')
let branch = split(filter(split(system('git branch'),'\n'),'v:val[0]=="*"')[0],'\s\+')[1]
let root = '/tmp/'.branch.'/vundle_bundles'
"let src = 'http://github.com/gmarik/vundle.git'
let src = '~/.vim/bundle/vundle/.git'
if !isdirectory(expand(root).'/vundle')
exec '!git clone '.src.' '.root.'/vundle'
endif
filetype off
syntax on
runtime macros/matchit.vim
exec 'set rtp+='.root.'/vundle'
call vundle#rc(root)
Bundle "gmarik/vundle"
" Vundle manages Vunlde
Bundle 'gmarik/vundle'
" vim-scripts name
Bundle 'molokai'
@ -49,19 +52,68 @@ Bundle 'rstacruz/sparkup.git', {'rtp': 'vim/'}
" Camel case
Bundle 'vim-scripts/RubySinatra'
" PostInstall
Bundle 'wincent/Command-T'
Bundle 'CSS3-Highlights'
augroup user#css3-highlights
au!
au User BundleInstallPre ! [ -d .git ] && git reset --hard
au User BundleInstallPost ! vim **/*.vim +'bufdo set fileformat=unix | wall | qall'
augroup end
" NOSYNC
" existing directory
Bundle! root.'/vundle/test/'
" just create one
Bundle! 'a_plugin'
"
" just create one, and override name
Bundle! 'b_plugin', {'name': 'zzz'}
filetype plugin indent on " Automatically detect file types.
set wildignore+=doc " should not break helptags
set wildignore+=.git " should not break clone
BundleInstall
augroup vimrc
au WinEnter * call Test()
augroup END
func! Test() abort
if 'ok' != g:vundle_test_plugin()
throw 'ooops'
endif
call Assert_bundles()
call Assert_a_bundle()
call Assert_b_bundle()
endf
func! Assert(cond, msg)
if !(a:cond)
throw a:msg
endif
endf
func! s:assert_bundles() abort
for b in g:bundles
if (!isdirectory(b.path().'/.git/'))
throw b.name.' not installed'
endif
func! Assert_bundles() abort
for b in g:vundle#bundles
call Assert(b.nosync() || b.installed(), b.name.' not installed')
endfor
endf
call s:assert_bundles()
func! Assert_a_bundle() abort
let b = filter(copy(g:vundle#bundles), 'v:val.name == "a_plugin"')[0]
let c = (b.path() == expand(g:vundle#bundle_dir.'/'.'a_plugin'))
call Assert(c, b.name.' isnt instaled')
endf
func! Assert_b_bundle() abort
let b = filter(copy(g:vundle#bundles), 'v:val.name == "zzz"')[0]
let c = (b.path() == expand(g:vundle#bundle_dir.'/'.'zzz'))
call Assert(c, b.name.' isnt instaled')
endf

Loading…
Cancel
Save