"ant.vim : VIM menu for using ant "Another Neat Tool (http://jakarta.apache.org/ant/index.html) "Author : Shad Gregory "$Revision: 0.3 "Keyboard Commands: " ,s -> This will prompt you for the location and name of the build " file. Not necessary if the build file is in the current " directory and named 'build.xml' " " ,b -> Executes 'ant -buildfile ' This will include any " option you have set via the menu. " " ,f -> Executes 'ant -find' along with any option you have set via " the menu. function! BuildTargetMenu() new silent! exec 'read '.g:buildFile silent! exec 'g/^$/d' "leave only target tags silent! exec 'g!/^\s' let menuString = '&ANT.\ Target.\ ' . getline(target) . ' ' . cmdString exe 'amenu ' . menuString . '' let target = target + 1 endwhile set nomodified bwipeout return 1 endfunction if exists("loaded_antmenu") aunmenu ANT else let loaded_antmenu=1 endif "globals let g:buildFile = './build.xml' let g:antOption = '' "keyboard shortcuts map ,b :call DoAntCmd(g:antOption.' -buildfile',g:buildFile) map ,s :call SetBuildFile() map ,f :call DoAntFind() "build ant menu amenu &ANT.\ &Build :call DoAntCmd(g:antOption.' -buildfile',g:buildFile) amenu &ANT.\ &Find :call DoAntFind() "parse build file if one exists in current directory if filereadable(g:buildFile) call BuildTargetMenu() endif amenu &ANT.\ &Set\ Option.\ &Quiet :let g:antOption = '-quiet' amenu &ANT.\ &Set\ Option.\ &Verbose :let g:antOption = '-verbose' amenu &ANT.\ &Set\ Option.\ &Debug :let g:antOption = '-debug' amenu &ANT.\ &Set\ Option.\ &Emacs :let g:antOption = '-emacs' amenu &ANT.\ &Set\ Option.\ &None :let g:antOption = '' amenu &ANT.\ &Set\ Option.\ &Display\ Current :echo g:antOption amenu &ANT.\ &Set\ build\ file :call SetBuildFile() amenu &ANT.\ &Help :call DoAntCmd('-help') amenu &ANT.\ &Version :call DoAntCmd('-version') "Allows user to set build.xml. If the file does not exist, gives a "statusline message and resets buildFile back to default. function! SetBuildFile() let g:buildFile=escape(input('build.xml location: '), '"<>|&') if !filereadable(g:buildFile) redraw echo g:buildFile.' does not exist!' let g:buildFile = './build.xml' return endif call BuildTargetMenu() return endfunction function! DoAntCmd(cmd,...) let regbak=@z if !exists("a:1") let @z=system('ant '.a:cmd) else if !filereadable(a:1) redraw echo 'build.xml is not readable!' return endif if exists("a:2") let @z=system('ant '.a:cmd.' '.a:1.' '.a:2) else let @z=system('ant '.a:cmd.' '.a:1) endif endif new silent normal "zP let @z=regbak endfunction function! DoAntFind(...) let regbak=@z let @z=system('ant '.g:antOption.' -find '.g:buildFile) new silent normal "zP let @z=regbak endfunction