Create a gist now

Instantly share code, notes, and snippets.

@uasi /vim.rb
Created Nov 30, 2010

Embed
Vim formula for Homebrew (EDIT: recent versions of official Homebrew distribution includes one)
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2'
head 'https://vim.googlecode.com/hg/'
sha256 '5c5d5d6e07f1bbc49b6fe3906ff8a7e39b049928b68195b38e3e3d347100221d'
version '7.3.682'
def features; %w(tiny small normal big huge) end
def interp; %w(lua mzscheme perl python python3 tcl ruby) end
def options
[
["--with-features=TYPE", "tiny, small, normal, big or huge (default: normal)"],
["--enable-interp=NAME,...", "lua, mzscheme, perl, python, python3, tcl and/or ruby"]
]
end
def patches
patch_level = version.to_s.split('.').last.to_i
{'p0' => (1..patch_level).map { |i| 'ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.%03d' % i }}
end
def install
def opt_val(opt)
opt.sub(/.*?=(.*)$/, "\\1") rescue nil
end
opts = []
feature = opt_val(ARGV.find {|s| s =~ /^--with-features=/ }) || "normal"
# For compatibility and convenience {{{
feature_shorthand = features.find {|f| ARGV.include? "--#{f}" }
feature = feature_shorthand if feature_shorthand
# }}}
opts << "--with-features=#{feature}"
interps = opt_val(ARGV.find {|s| s =~ /^--enable-interp=/ }) || ""
interps = interps.split(/,/)
# For compatibility and convenience {{{
interp.each do |i|
if ARGV.include? "--#{i}"
interps << i
end
end
# }}}
interps.uniq!
interps.each do |i|
opts << "--enable-#{i}interp=yes"
opts << "--with-lua-prefix=/usr/local" if i == "lua"
end
system "./configure",
"--disable-gui",
"--without-x",
"--disable-gpm",
"--disable-nls",
"--with-tlib=ncurses",
"--enable-multibyte",
"--prefix=#{prefix}",
"--mandir=#{man}",
*opts
system "make install"
end
end
@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi Nov 30, 2010

To install this formula, right-click 'raw' at the top-right corner of the text area, copy URL, and run the following command:

brew install https://raw.github.com/gist/721952/vim.rb --HEAD [options]

Options are:

--HEAD                     (check out the most recent source code from repo; recommended)
--with-features=<TYPE>     (--<TYPE> for short)
--enable-interp=<NAME>,... (--<NAME> for short)
Owner

uasi commented Nov 30, 2010

To install this formula, right-click 'raw' at the top-right corner of the text area, copy URL, and run the following command:

brew install https://raw.github.com/gist/721952/vim.rb --HEAD [options]

Options are:

--HEAD                     (check out the most recent source code from repo; recommended)
--with-features=<TYPE>     (--<TYPE> for short)
--enable-interp=<NAME>,... (--<NAME> for short)
@claytron

This comment has been minimized.

Show comment
Hide comment
@claytron

claytron Dec 12, 2010

This works great, thx!

Would be great if the options allowed for enabling the interpreters (python, perl, ruby, etc.).

This works great, thx!

Would be great if the options allowed for enabling the interpreters (python, perl, ruby, etc.).

@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi Dec 12, 2010

Added interp options.

If you want finer control, you should run ./configure for yourself :)

Owner

uasi commented Dec 12, 2010

Added interp options.

If you want finer control, you should run ./configure for yourself :)

@gaving

This comment has been minimized.

Show comment
Hide comment
@gaving

gaving Dec 28, 2010

Perplexed why this wasn't working by default!

Working great, cheers.

gaving commented Dec 28, 2010

Perplexed why this wasn't working by default!

Working great, cheers.

@claytron

This comment has been minimized.

Show comment
Hide comment
@claytron

claytron Jan 16, 2011

I can no longer get this to work for me. I get the following error:

Error: undefined method `include' for ["--", "--big", "--python", "--ruby", "--perl"]:Array

It worked before, but now it doesn't. Any idea why?

I can no longer get this to work for me. I get the following error:

Error: undefined method `include' for ["--", "--big", "--python", "--ruby", "--perl"]:Array

It worked before, but now it doesn't. Any idea why?

@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi Jan 16, 2011

@claytron

Thanks for reporting the bug. Fixed typo.

Owner

uasi commented Jan 16, 2011

@claytron

Thanks for reporting the bug. Fixed typo.

@claytron

This comment has been minimized.

Show comment
Hide comment
@claytron

claytron Jan 16, 2011

Works again, thx!

Works again, thx!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 7, 2011

Thank you :) Vim is my choice of editor and this really helps me stay up to date.

ghost commented Feb 7, 2011

Thank you :) Vim is my choice of editor and this really helps me stay up to date.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 19, 2011

Just wanted to let you know this does not pass brew audit.

vim:
 * Option --tiny is unused
 * Option --small is unused
 * Option --normal is unused
 * Option --big is unused
 * Option --huge is unused

Is there any way possible to "fix" this?

ghost commented Feb 19, 2011

Just wanted to let you know this does not pass brew audit.

vim:
 * Option --tiny is unused
 * Option --small is unused
 * Option --normal is unused
 * Option --big is unused
 * Option --huge is unused

Is there any way possible to "fix" this?

@telemachus

This comment has been minimized.

Show comment
Hide comment
@telemachus

telemachus Feb 23, 2011

I have a quick question: shouldn't the features option be more like this?

"--with-features=#{feature}"

Also, in order to build Lua, --enable-luainterp needs help. You also need --with-lua-prefix=/usr/local and (more importantly), I think you need to manually download the static library that Vim needs to build against and install it in /usr/local/lib. See these links for more details:

I have a quick question: shouldn't the features option be more like this?

"--with-features=#{feature}"

Also, in order to build Lua, --enable-luainterp needs help. You also need --with-lua-prefix=/usr/local and (more importantly), I think you need to manually download the static library that Vim needs to build against and install it in /usr/local/lib. See these links for more details:

@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi Feb 23, 2011

@MindTooth

Thanks, made a workaround for that.

@telemachus

Now uses --with-features= option. Thanks.
Also added --with-lua-prefix=/usr/local for Lua.

Owner

uasi commented Feb 23, 2011

@MindTooth

Thanks, made a workaround for that.

@telemachus

Now uses --with-features= option. Thanks.
Also added --with-lua-prefix=/usr/local for Lua.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 23, 2011

Thank you for updating ;)

ghost commented Feb 23, 2011

Thank you for updating ;)

@shapeshed

This comment has been minimized.

Show comment
Hide comment
@shapeshed

shapeshed Mar 3, 2011

Thank you! Is there are a reason this isn't available directly in homebrew? Works great here!

Thank you! Is there are a reason this isn't available directly in homebrew? Works great here!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 3, 2011

The policy of Homebrew is to not include system duplicates.

ghost commented Mar 3, 2011

The policy of Homebrew is to not include system duplicates.

@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi Mar 3, 2011

@shapeshed

Homebrew doesn't accept "duplicate" formulae; see Acceptable Formula.

Owner

uasi commented Mar 3, 2011

@shapeshed

Homebrew doesn't accept "duplicate" formulae; see Acceptable Formula.

@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi Mar 3, 2011

Update (64bbe5..b1cf39):

Added head URL, tidied up options, and purged nasty workarounds.
Now you don't have to fork this formula only to bump patchlevel; use --HEAD instead!

Owner

uasi commented Mar 3, 2011

Update (64bbe5..b1cf39):

Added head URL, tidied up options, and purged nasty workarounds.
Now you don't have to fork this formula only to bump patchlevel; use --HEAD instead!

@gaving

This comment has been minimized.

Show comment
Hide comment
@gaving

gaving Mar 3, 2011

Vote to make vim exempt!

gaving commented Mar 3, 2011

Vote to make vim exempt!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 23, 2011

.143 is released ;)

ghost commented Mar 23, 2011

.143 is released ;)

@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi Mar 23, 2011

Updated, thanks.

Owner

uasi commented Mar 23, 2011

Updated, thanks.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 23, 2011

Maybe I could suggest that you submit this to the homebrew-alt repo?

Thank you for updating ;)

ghost commented Mar 23, 2011

Maybe I could suggest that you submit this to the homebrew-alt repo?

Thank you for updating ;)

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 28, 2011

7.3.146 is released ;)

7.3.144 crash with ":python help(dir)"

7.3.145 (after 7.3.144) can't build with Python dynamically loading

7.3.146 can assign to dict member with invalid name

Can't you make the patchlevel def read from the version tag? I'm not know with Ruby, so I can't help out. But that would be much easier, than updating the same info two places :)

ghost commented Mar 28, 2011

7.3.146 is released ;)

7.3.144 crash with ":python help(dir)"

7.3.145 (after 7.3.144) can't build with Python dynamically loading

7.3.146 can assign to dict member with invalid name

Can't you make the patchlevel def read from the version tag? I'm not know with Ruby, so I can't help out. But that would be much easier, than updating the same info two places :)

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 13, 2011

I've tweaked my fork and updated it: https://gist.github.com/896531
161 is relased as well.

ghost commented Apr 13, 2011

I've tweaked my fork and updated it: https://gist.github.com/896531
161 is relased as well.

@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi Apr 13, 2011

@MindTooth

Thanks, merged your work :)

Maybe I could suggest that you submit this to the homebrew-alt repo?

homebrew(-alt) seems to prefer a formula that comes with a recommended configuration.
This one is bit too configurable for them, I think.

Owner

uasi commented Apr 13, 2011

@MindTooth

Thanks, merged your work :)

Maybe I could suggest that you submit this to the homebrew-alt repo?

homebrew(-alt) seems to prefer a formula that comes with a recommended configuration.
This one is bit too configurable for them, I think.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 16, 2011

Any suggestions on how to make this compile with a Ruby version from RVM? I'm a bit stuck atm.

ghost commented Apr 16, 2011

Any suggestions on how to make this compile with a Ruby version from RVM? I'm a bit stuck atm.

@telemachus

This comment has been minimized.

Show comment
Hide comment
@telemachus

telemachus Apr 16, 2011

@MindTooth I've never been able to get that to work. I simply turn off rvm temporary (rvm use system), then build vim, then turn rvm back on.

If it makes you feel any better, Vim simply ignores my Homebrew-installed Python (even though it's first in my $PATH). So it's not just Ruby.

@MindTooth I've never been able to get that to work. I simply turn off rvm temporary (rvm use system), then build vim, then turn rvm back on.

If it makes you feel any better, Vim simply ignores my Homebrew-installed Python (even though it's first in my $PATH). So it's not just Ruby.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 17, 2011

Thank you for the tip. It did the trick!

I hope that we can provide something for the future at a later time ;) Will look into it more whenever I have the time and the knowledge to do so.

ghost commented Apr 17, 2011

Thank you for the tip. It did the trick!

I hope that we can provide something for the future at a later time ;) Will look into it more whenever I have the time and the knowledge to do so.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 3, 2011

7.3.170 is released ;)

ghost commented May 3, 2011

7.3.170 is released ;)

@uasi

This comment has been minimized.

Show comment
Hide comment
Owner

uasi commented May 3, 2011

@MindTooth

Thanks :)

@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi May 3, 2011

Added head URL, which had been removed accidentally.

Owner

uasi commented May 3, 2011

Added head URL, which had been removed accidentally.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 7, 2011

7.3.177 is released ;)

ghost commented May 7, 2011

7.3.177 is released ;)

@asenchi

This comment has been minimized.

Show comment
Hide comment
@asenchi

asenchi May 10, 2011

So has anyone been able to get this to work with hombrew-installed Python? Need to find a solution here, since I'd prefer to use Python 3.

asenchi commented May 10, 2011

So has anyone been able to get this to work with hombrew-installed Python? Need to find a solution here, since I'd prefer to use Python 3.

@ghost

This comment has been minimized.

Show comment
Hide comment
@asenchi

This comment has been minimized.

Show comment
Hide comment
@asenchi

asenchi May 11, 2011

Not necessarily. Ultimately I want to compile vim with support for my Homebrew installed Python version and not the default Python shipped with Mac OS X. (Whether 2 or 3 isn't that big a deal, though I was hoping to port existing python plugins to 3).

asenchi commented May 11, 2011

Not necessarily. Ultimately I want to compile vim with support for my Homebrew installed Python version and not the default Python shipped with Mac OS X. (Whether 2 or 3 isn't that big a deal, though I was hoping to port existing python plugins to 3).

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 11, 2011

http://forums.freebsd.org/showthread.php?t=22962

What I found out now is, that for compiling vim with Python3-support, the python header files are needed. For Ubuntu, they are in the package python-dev, but there is no python-dev in the ports. After using google, it seems that a file named python.h is needed, but there is no python.h on my system and I don't know where to get it.

Seems like you need to the header file. Or am I mistaken?

ghost commented May 11, 2011

http://forums.freebsd.org/showthread.php?t=22962

What I found out now is, that for compiling vim with Python3-support, the python header files are needed. For Ubuntu, they are in the package python-dev, but there is no python-dev in the ports. After using google, it seems that a file named python.h is needed, but there is no python.h on my system and I don't know where to get it.

Seems like you need to the header file. Or am I mistaken?

@asenchi

This comment has been minimized.

Show comment
Hide comment
@asenchi

asenchi May 11, 2011

Sorry, I am not being clear, for example, using the formula above, if I brew install with python, then add:

python <<EOF
import sys
print(sys.version)
EOF

to my .vimrc, it says I am using the Python shipped with Snow Leopard.

I've hardcoded the following into the formula and it still doesn't work:

  "--enable-pythoninterp=yes",
  "--with-python-config-dir=/usr/local/lib/python2.7/config",

Any ideas how to get this forumla to see it? I am going to keep hacking around, but thus far I have yet to find a solution.

asenchi commented May 11, 2011

Sorry, I am not being clear, for example, using the formula above, if I brew install with python, then add:

python <<EOF
import sys
print(sys.version)
EOF

to my .vimrc, it says I am using the Python shipped with Snow Leopard.

I've hardcoded the following into the formula and it still doesn't work:

  "--enable-pythoninterp=yes",
  "--with-python-config-dir=/usr/local/lib/python2.7/config",

Any ideas how to get this forumla to see it? I am going to keep hacking around, but thus far I have yet to find a solution.

@neezer

This comment has been minimized.

Show comment
Hide comment
@Soliah

This comment has been minimized.

Show comment
Hide comment
@Soliah

Soliah Jun 26, 2011

Just a note for anyone using this now - there seems to be a problem with one of the patches: https://groups.google.com/group/vim_dev/msg/4ecb0d64e2c0dc5d

I just removed the patch method for now to get it installed.

Soliah commented Jun 26, 2011

Just a note for anyone using this now - there seems to be a problem with one of the patches: https://groups.google.com/group/vim_dev/msg/4ecb0d64e2c0dc5d

I just removed the patch method for now to get it installed.

@ijt

This comment has been minimized.

Show comment
Hide comment
@ijt

ijt Jul 13, 2011

Thanks for writing this! The system Vim is missing a lot of stuff I depend on.

ijt commented Jul 13, 2011

Thanks for writing this! The system Vim is missing a lot of stuff I depend on.

@telemachus

This comment has been minimized.

Show comment
Hide comment
@telemachus

telemachus Sep 28, 2011

Fyi: I've been using a variant of this for a few months with good success: https://gist.github.com/1027452.

The only significant difference is that I leverage Mercurial in order to avoid downloading all the patches separately each time. In order to update it, I simply edit the :revision and version numbers.

Fyi: I've been using a variant of this for a few months with good success: https://gist.github.com/1027452.

The only significant difference is that I leverage Mercurial in order to avoid downloading all the patches separately each time. In order to update it, I simply edit the :revision and version numbers.

@uasi

This comment has been minimized.

Show comment
Hide comment
@uasi

uasi Sep 29, 2011

@telemachus Thanks, that will reduce build time and server load!

(As a side note, I've chosen not to use Mercurial to fetch a specific version of Vim because:

  1. it is possible to skip specific (maybe flawed) patches by modifying the patches method,
  2. you can always use --HEAD to fetch the most recent revision with Mercurial, like brew install vim --HEAD, and
  3. I love a coffee break watching growing 300+ progress bars ;-)
Owner

uasi commented Sep 29, 2011

@telemachus Thanks, that will reduce build time and server load!

(As a side note, I've chosen not to use Mercurial to fetch a specific version of Vim because:

  1. it is possible to skip specific (maybe flawed) patches by modifying the patches method,
  2. you can always use --HEAD to fetch the most recent revision with Mercurial, like brew install vim --HEAD, and
  3. I love a coffee break watching growing 300+ progress bars ;-)
@1stevengrant

This comment has been minimized.

Show comment
Hide comment
@1stevengrant

1stevengrant Dec 23, 2011

I got the error:
/usr/bin/patch: **** Can't open patch file 065-homebrew.diff : No such file or directory
Error: Failure while executing: /usr/bin/patch -f -p0 -i 065-homebrew.diff

I got the error:
/usr/bin/patch: **** Can't open patch file 065-homebrew.diff : No such file or directory
Error: Failure while executing: /usr/bin/patch -f -p0 -i 065-homebrew.diff

@evidens

This comment has been minimized.

Show comment
Hide comment
@evidens

evidens Apr 16, 2012

I made a slight modification to the fork by telemachus to make using the homebrew python easy https://gist.github.com/2402135

when you use --use-brew-python flag it will add the option "--with-python-config-dir=/usr/local/lib/python2.7/config"

evidens commented Apr 16, 2012

I made a slight modification to the fork by telemachus to make using the homebrew python easy https://gist.github.com/2402135

when you use --use-brew-python flag it will add the option "--with-python-config-dir=/usr/local/lib/python2.7/config"

@just3ws

This comment has been minimized.

Show comment
Hide comment
@just3ws

just3ws Apr 20, 2012

This is just for my understanding. Why not just use MacVim? I run MacVim on OS X in my terminal with a simple alias, but also get the option to run it as a full windowed app.

in my .bashrc

alias vim="mvim -v"
alias vi="mvim -v"

Is there something I'm missing about MacVim vs Vim?

Thanks.

just3ws commented Apr 20, 2012

This is just for my understanding. Why not just use MacVim? I run MacVim on OS X in my terminal with a simple alias, but also get the option to run it as a full windowed app.

in my .bashrc

alias vim="mvim -v"
alias vi="mvim -v"

Is there something I'm missing about MacVim vs Vim?

Thanks.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 20, 2012

Vim is updated more often than MacVim from my understanding at least.

ghost commented Apr 20, 2012

Vim is updated more often than MacVim from my understanding at least.

@ijt

This comment has been minimized.

Show comment
Hide comment
@ijt

ijt Apr 20, 2012

ijt commented Apr 20, 2012

@morygonzalez

This comment has been minimized.

Show comment
Hide comment
@morygonzalez

morygonzalez Sep 8, 2012

@uasi ここの version 、一旦 to_s しないとエラー出るようになってるっぽいですよ。

patch_level = version.split('.').last.to_i

@uasi ここの version 、一旦 to_s しないとエラー出るようになってるっぽいですよ。

patch_level = version.split('.').last.to_i
@diogeneshamilton

This comment has been minimized.

Show comment
Hide comment
@diogeneshamilton

diogeneshamilton Sep 12, 2012

latest version of brew does not allow split directly, use to_s like in this: https://gist.github.com/3423922

latest version of brew does not allow split directly, use to_s like in this: https://gist.github.com/3423922

@Enrico68

This comment has been minimized.

Show comment
Hide comment
@Enrico68

Enrico68 Jul 23, 2014

I have problem installing vim with anaconda Python. All plugin with Python code are not working. Is there a way to circumvent this problem ?

I have problem installing vim with anaconda Python. All plugin with Python code are not working. Is there a way to circumvent this problem ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment