Skip to content

Instantly share code, notes, and snippets.

@iapilgrim
Forked from jhbabon/vim_installer.rb
Created April 18, 2014 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iapilgrim/11023356 to your computer and use it in GitHub Desktop.
Save iapilgrim/11023356 to your computer and use it in GitHub Desktop.
require 'thor'
class VimInstaller < Thor::Group
include Thor::Actions
def self.source_root
'/tmp'
end
def clean_up
vimify :clean, 'Cleaning previous installations' do
run 'rm -fr vim'
end
end
def set_up
say_status :setup, 'Setup system ruby', :white
run 'rbenv global system'
end
def download_vim
vimify :download, 'Downloading VIM' do
run 'hg clone https://vim.googlecode.com/hg/ vim'
end
end
def configure_vim
vimify :configure, 'Configuring VIM', 'vim' do
options = ['--with-features=huge',
'--enable-cscope',
'--enable-pythoninterp',
'--enable-rubyinterp',
'--enable-perlinterp',
'--enable-multibyte',
'--enable-clipboard=yes',
'--enable-xterm_clipboard=yes']
run "./configure #{options.join(' ')}"
end
end
def set_arch_vim
vimify :arch, 'Setting VIM arch', 'vim' do
arch = "-arch x86_64"
gsub_file 'src/auto/config.mk', /.*LDFLAGS.*/, "LDFLAGS = -L. #{arch} -L/usr/local/lib"
end
end
def make_vim
vimify :make, 'Making VIM', 'vim' do
run_with_gcc 'make'
end
end
def verify_vim
vimify :verify, 'Verifying VIM', 'vim/src' do
run './vim --version'
end
end
def install_vim
vimify :install, 'Installing VIM', 'vim' do
if yes?('Install VIM in /usr/bin [yes/no]? ')
run_with_gcc 'sudo make install'
say_status :install, "old vim symlink moved to /usr/bin/vim.old", :white
run "sudo mv /usr/bin/vim /usr/bin/vim.old"
run "sudo ln -s /usr/local/bin/vim /usr/bin/vim"
else
say 'Skipping'
end
end
end
def tear_down
say_status :setup, 'Setup 1.9.3-p194 ruby', :white
run 'rbenv global 1.9.3-p194'
end
private
def vimify(status, message, dir = nil, &block)
say_status status, message, :white
if dir
inside dir, &block
else
in_root &block
end
end
def run_with_gcc(cmd)
# resolve some weird problems with XCode 4.3 and rbenv
run "env CC=/usr/bin/gcc #{cmd}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment