diff --git a/Rakefile b/Rakefile index 0b3d4be..0d29fe3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ require 'rake' +require 'fileutils' desc "Hook our dotfiles into system-standard positions." task :install => [:submodule_init, :submodules] do @@ -18,7 +19,10 @@ task :install => [:submodule_init, :submodules] do file_operation(Dir.glob('ctags/*')) if want_to_install?('ctags config (better js/ruby support)') file_operation(Dir.glob('tmux/*')) if want_to_install?('tmux config') file_operation(Dir.glob('vimify/*')) if want_to_install?('vimification of command line tools') - file_operation(Dir.glob('{vim,vimrc}')) if want_to_install?('vim configuration (highly recommended)') + if want_to_install?('vim configuration (highly recommended)') + file_operation(Dir.glob('{vim,vimrc}')) + Rake::Task["install_vundle"].execute + end Rake::Task["install_prezto"].execute @@ -35,7 +39,9 @@ task :install_prezto do end end -task :update => [:install] do +task :update do + Rake::Task["vundle_migration"].execute if needs_migration_to_vundle? + Rake::Task["install"] #TODO: for now, we do the same as install. But it would be nice #not to clobber zsh files end @@ -62,6 +68,49 @@ task :submodules do end end +desc "Performs migration from pathogen to vundle" +task :vundle_migration do + puts "======================================================" + puts "Migrating from pathogen to vundle vim plugin manager. " + puts "This will move the old .vim/bundle directory to" + puts ".vim/bundle.old and replacing all your vim plugins with" + puts "the standard set of plugins. You will then be able to " + puts "manage your vim's plugin configuration by editing the " + puts "file .vim/vundles.vim" + puts "======================================================" + + Dir.glob(File.join('vim', 'bundle','**')) do |sub_path| + run %{git config -f #{File.join('.git', 'config')} --remove-section submodule.#{sub_path}} + # `git rm --cached #{sub_path}` + FileUtils.rm_rf(File.join('.git', 'modules', sub_path)) + end + FileUtils.mv(File.join('vim','bundle'), File.join('vim', 'bundle.old')) + run %{ + cd $HOME/.yadr + git clone https://github.com/gmarik/vundle.git #{File.join('vim','bundle', 'vundle')} + } +end + +desc "Runs Vundle installer in a clean vim environment" +task :install_vundle do + puts "======================================================" + puts "Installing vundle." + puts "The installer will now proceed to run BundleInstall." + puts "Due to a bug, the installer may report some errors" + puts "when installing the plugin 'syntastic'. Fortunately" + puts "Syntastic will install and work properly despite the" + puts "errors so please just ignore them and let's hope for" + puts "an update that fixex the problem!" + puts "======================================================" + + puts "" + puts "Press a key to continue" + STDIN.getc + + system "vim --noplugin -u vim/vundles.vim -N \"+set hidden\" \"+syntax on\" +BundleClean +BundleInstall +qall" + +end + task :default => 'install' @@ -194,6 +243,17 @@ def file_operation(files, method = :symlink) end end +def needs_migration_to_vundle? + File.exists? File.join('vim', 'bundle', 'tpope-vim-pathogen') +end + + +def list_vim_submodules + result=`git submodule -q foreach 'echo $name"||"\`git remote -v | awk "END{print \\\\\$2}"\`'`.select{ |line| line =~ /^vim.bundle/ }.map{ |line| line.split('||') } + Hash[*result.flatten] +end + + def success_msg(action) puts "" puts " _ _ _ "