# Reference: https://github.com/macvim-dev/macvim/wiki/building class Macvim < Formula desc "GUI for vim, made for macOS" homepage "https://github.com/macvim-dev/macvim" url "https://github.com/macvim-dev/macvim/archive/refs/tags/release-174.tar.gz" version "9.0.472" sha256 "9481eeca43cfc0a7cf0604088c4b536f274821adb62b0daefada978aa7f4c41b" license "Vim" head "https://github.com/macvim-dev/macvim.git", branch: "master" bottle do sha256 arm64_monterey: "4cafa590c301a6faac579c80051f6a1d42aceaaf696543efd5c7534a7264b51c" sha256 arm64_big_sur: "037d8c6d8cbff48e3fb5283da6f6a33b0bdc670cd36e4c7e41c38db055e2ae92" sha256 monterey: "3806ba7bc7a4e8df772ca3b61ae1d6d04fadcb06498cb4163dce6ac665e114cc" sha256 big_sur: "2aa6b6157a1710b99972c00e48bef79b4aa5568b412202cd126b5f7b9ac3874f" sha256 catalina: "eee0fe997e9a555af90726a304e649b74833bcf7026d483dcc22d0ea07b11232" end depends_on xcode: :build depends_on "cscope" depends_on "gettext" depends_on "lua" depends_on :macos depends_on "python@3.10" depends_on "ruby" conflicts_with "vim", because: "vim and macvim both install vi* binaries" def install # Avoid issues finding Ruby headers ENV.delete("SDKROOT") # MacVim doesn't have or require any Python package, so unset PYTHONPATH ENV.delete("PYTHONPATH") # make sure that CC is set to "clang" ENV.clang system "./configure", "--with-features=huge", "--enable-multibyte", "--enable-perlinterp", "--enable-rubyinterp", "--enable-tclinterp", "--enable-terminal", "--with-tlib=ncurses", "--with-compiledby=Homebrew", "--with-local-dir=#{HOMEBREW_PREFIX}", "--enable-cscope", "--enable-luainterp", "--with-lua-prefix=#{Formula["lua"].opt_prefix}", "--enable-luainterp", "--enable-python3interp", "--disable-sparkle", "--with-macarchs=#{Hardware::CPU.arch}" system "make" prefix.install "src/MacVim/build/Release/MacVim.app" # Remove autoupdating universal binaries (prefix/"MacVim.app/Contents/Frameworks/Sparkle.framework").rmtree bin.install_symlink prefix/"MacVim.app/Contents/bin/mvim" # Create MacVim vimdiff, view, ex equivalents executables = %w[mvimdiff mview mvimex gvim gvimdiff gview gvimex] executables += %w[vi vim vimdiff view vimex] executables.each { |e| bin.install_symlink "mvim" => e } end test do output = shell_output("#{bin}/mvim --version") assert_match "+ruby", output assert_match "+gettext", output # Simple test to check if MacVim was linked to Homebrew's Python 3 py3_exec_prefix = shell_output(Formula["python@3.10"].opt_libexec/"bin/python-config --exec-prefix") assert_match py3_exec_prefix.chomp, output (testpath/"commands.vim").write <<~EOS :python3 import vim; vim.current.buffer[0] = 'hello python3' :wq EOS system bin/"mvim", "-v", "-T", "dumb", "-s", "commands.vim", "test.txt" assert_equal "hello python3", (testpath/"test.txt").read.chomp end end