Macos – How to change or edit Vim Homebrew recipe

homebrewmacosvim

I use a Vim plugin that requires +clientserver, and the default brew Vim recipe does not include the appropriate flags, so I'm trying to add it to the ./configure step.

I tried building Vim from source, but without success. I would like to try either using an alternate recipe — there's one with the flags set that I require here — or perhaps editing the Homebrew recipe itself … however I am unsure how to proceed.

Can someone please give me some pointers to help me get started using either the alternate recipe, or with editing the Homebrew recipe itself?

Ultimately, I would like to learn how to do both things.


to compile terminal vim with the clientserver features, i did the following:

brew edit vim

and edited the ./configure options as follows (removed --enable-gui=no, and --without-x, and added --enable-gui=gtk2):

system "./configure", "--prefix=#{HOMEBREW_PREFIX}",
                      "--mandir=#{man}",
                      "--disable-nls",
                      "--enable-multibyte",
                      "--with-tlib=ncurses",
                      "--enable-cscope",
                      "--enable-rubyinterp",                            
                      "--enable-pythoninterp",
                      "--enable-gui=gtk2",
                      "--with-features=huge",
                       *language_opts

Then rvm use system (a ruby bug workaround that's always required for brewing vim); then brew install vim; and finally brew unlink vim && brew link vim.

To install from the target URL:

brew install https://gist.github.com/2004942/vim.rb

(though in this case, it is not what i did).

Best Answer

Here's how to edit a Homebrew formula:

brew edit formula

So, in your case that'd be brew edit vim. Save, and reinstall. The edited formula is cached locally until you update Homebrew—if I recall correctly, you'll be asked what to do with your changed formula once you update Brew.

You could even go as far as creating your own formula though, which is explained in the Formula Cookbook. The basic steps are:

  • Create a tarball for your software and call brew create for that URL e.g. brew create http://example.com/foo-0.1.tar.gz
  • Build it with brew install -vd foo, where debugging and verbose mode is on
Related Question