Skip to content

Commit

Permalink
Experimental BundleMake command
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarik committed Oct 17, 2011
1 parent 304e636 commit 5d2a24f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
3 changes: 3 additions & 0 deletions autoload/vundle.vim
Expand Up @@ -16,6 +16,9 @@ com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleSearch
com! -nargs=? -bang -complete=custom,vundle#scripts#complete Bundles
\ call vundle#scripts#all('!'=='<bang>', <q-args>)

com! -nargs=1 -bang BundleMake
\ call vundle#config#add_make_cmd(<q-args>)

com! -nargs=0 -bang BundleList
\ call vundle#installer#list('!'=='<bang>')

Expand Down
9 changes: 9 additions & 0 deletions autoload/vundle/config.vim
Expand Up @@ -27,6 +27,11 @@ func! vundle#config#init_bundle(name, opts)
return extend(opts, copy(s:bundle))
endf

func! vundle#config#add_make_cmd(cmd)
" TODO: handle error
call g:bundles[-1].set_make_cmd(a:cmd)
endf

func! s:parse_options(opts)
" TODO: improve this
if len(a:opts) != 1 | return {} | endif
Expand Down Expand Up @@ -84,6 +89,10 @@ endf

let s:bundle = {}

func! s:bundle.set_make_cmd(cmd)
call extend(self, {'make_cmd': a:cmd})
endf

func! s:bundle.path()
return s:expand_path(g:bundle_dir.'/'.self.name)
endf
Expand Down
18 changes: 16 additions & 2 deletions autoload/vundle/installer.vim
Expand Up @@ -4,14 +4,14 @@ func! vundle#installer#new(bang, ...) abort
\ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})')

let names = vundle#scripts#bundle_names(map(copy(bundles), 'v:val.name_spec'))
call vundle#scripts#view('Installer',['" Installing bundles to '.expand(g:bundle_dir)], names + ['Helptags'])
let make_cmds = vundle#scripts#bundle_make_cmds(bundles)
call vundle#scripts#view('Installer',['" Installing bundles to '.expand(g:bundle_dir)], names + make_cmds + ['Helptags'])

call s:process(a:bang, (a:bang ? 'add!' : 'add'))

call vundle#config#require(bundles)
endf


func! s:process(bang, cmd)
let msg = ''

Expand Down Expand Up @@ -96,6 +96,20 @@ func! vundle#installer#install(bang, name) abort
return s:sync(a:bang, b)
endf

func! vundle#installer#make(name) abort
call s:log(' ')
call s:log('Make: '.a:name)

let b = filter(copy(g:bundles), 'v:val.name_spec ==? "'.a:name.'"')[0]

try
silent exec b.make_cmd
return 'updated'
catch
return 'error'
endtry
endf

func! vundle#installer#docs() abort
call vundle#installer#helptags(g:bundles)
return 'updated'
Expand Down
11 changes: 10 additions & 1 deletion autoload/vundle/scripts.vim
Expand Up @@ -33,10 +33,15 @@ func! s:view_log()
wincmd P | wincmd H
endf

func vundle#scripts#bundle_names(names)
func! vundle#scripts#bundle_names(names)
return map(copy(a:names), ' printf("Bundle ' ."'%s'".'", v:val) ')
endf

func! vundle#scripts#bundle_make_cmds(bundles)
let bundles_with_make = filter(copy(a:bundles), 'has_key(v:val, "make_cmd")')
return map(bundles_with_make, ' printf("Make ' ."'%s'".' '.'", v:val.name_spec) ')
endf

func! vundle#scripts#view(title, headers, results)
if exists('g:vundle_view') && bufloaded(g:vundle_view)
exec g:vundle_view.'bd!'
Expand All @@ -61,6 +66,7 @@ func! vundle#scripts#view(title, headers, results)
setl syntax=vim
syn keyword vimCommand Bundle
syn keyword vimCommand Helptags
syn keyword vimCommand Make

com! -buffer -bang -nargs=1 DeleteBundle
\ call vundle#installer#run('vundle#installer#delete', split(<q-args>,',')[0], ['!' == '<bang>', <args>])
Expand All @@ -71,6 +77,9 @@ func! vundle#scripts#view(title, headers, results)
com! -buffer -bang -nargs=? InstallBundle
\ call vundle#installer#run('vundle#installer#install', split(<q-args>,',')[0], ['!' == '<bang>', <q-args>])

com! -buffer -bar -bang -nargs=1 InstallMake
\ call vundle#installer#run('vundle#installer#make', split(<q-args>,',')[0], [split(<args>,',')[0]])

com! -buffer -bang -nargs=0 InstallHelptags
\ call vundle#installer#run('vundle#installer#docs', 'helptags', [])

Expand Down
4 changes: 4 additions & 0 deletions test/vimrc
Expand Up @@ -52,6 +52,10 @@ Bundle 'rstacruz/sparkup.git', {'rtp': 'vim/'}
" Camel case
Bundle 'vim-scripts/RubySinatra'

Bundle 'wincent/Command-T.git'
BundleMake :ruby puts( cmd = "cd #{File.expand_path($LOAD_PATH.grep(/command-?t/i).first)}/command-t/ && git checkout -f master && ruby extconf.rb && make clean && make");
\ system(cmd)

filetype plugin indent on " Automatically detect file types.

set wildignore+=doc " should not break helptags
Expand Down

2 comments on commit 5d2a24f

@jdevera
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions:

  1. Does this cover the same use case than the events thingy?
  2. A BundleMake command applies only to the Bundle defined immediately before?

@gmarik
Copy link
Contributor Author

@gmarik gmarik commented on 5d2a24f Oct 25, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. yes, but it's a bit easier to use, comparing to existing implementation of "events". Though eventually events are the way to go i think
  2. yes

Please sign in to comment.