class Vim < Formula desc "Vi 'workalike' with many additional features" homepage "https://www.vim.org/" # vim should only be updated every 50 releases on multiples of 50 url "https://github.com/vim/vim/archive/refs/tags/v9.1.2100.tar.gz" sha256 "5042505291ff23f8388013b48c034dea13f4eea322880d077b0ce7c8210bd618" license "Vim" head "https://github.com/vim/vim.git", branch: "master" # The Vim repository contains thousands of tags and the `Git` strategy isn't # ideal in this context. This is an exceptional situation, so this checks the # first 50 tags using the GitHub API (to minimize data transfer). livecheck do url "https://api.github.com/repos/vim/vim/tags?per_page=50" regex(/^v?(\d+(?:\.\d+)+)$/i) strategy :json do |json, regex| json.map do |tag| match = tag["name"]&.match(regex) next if match.blank? match[1] end end throttle 50 end bottle do sha256 arm64_tahoe: "24dcdc713a9bb052b14b1ba5518c56238e1840e55a5ddee0b4a7804b67fdf2c9" sha256 arm64_sequoia: "0f02877d2fd160ac5f343060cf365593dbcb0bcb7550552f450f009d053aa893" sha256 arm64_sonoma: "95718156457b88800e322a65f1dff0cf43a1464b4c267c54f25b43fa10927972" sha256 sonoma: "13bbe67da85885050615587a6d5593ff9b929627aa55066871972afa06460502" sha256 arm64_linux: "9e37841b13cb15f92e1a8f46343b7e2da4687f8cdd8dd01b2f17f4d9aef47e49" sha256 x86_64_linux: "46b2beab009da10ef090c5f32f42f52504866b29ea008c251ae2402f7c7016e6" end depends_on "gettext" => :build depends_on "libsodium" depends_on "lua" depends_on "ncurses" depends_on "python@3.14" depends_on "ruby" uses_from_macos "perl" on_macos do depends_on "gettext" end on_linux do depends_on "acl" end conflicts_with "ex-vi", because: "vim and ex-vi both install bin/ex and bin/view" conflicts_with "macvim", because: "vim and macvim both install vi* binaries" def install ENV.prepend_path "PATH", Formula["python@3.14"].opt_libexec/"bin" # https://github.com/Homebrew/homebrew-core/pull/1046 ENV.delete("SDKROOT") # vim doesn't require any Python package, unset PYTHONPATH. ENV.delete("PYTHONPATH") ENV.append_to_cflags "-mllvm -enable-constraint-elimination=0" if DevelopmentTools.clang_build_version == 1600 # We specify HOMEBREW_PREFIX as the prefix to make vim look in the # the right place (HOMEBREW_PREFIX/share/vim/{vimrc,vimfiles}) for # system vimscript files. We specify the normal installation prefix # when calling "make install". # Homebrew will use the first suitable Perl & Ruby in your PATH if you # build from source. Please don't attempt to hardcode either. system "./configure", "--prefix=#{HOMEBREW_PREFIX}", "--mandir=#{man}", "--enable-multibyte", "--with-tlib=ncurses", "--with-compiledby=Homebrew", "--enable-cscope", "--enable-terminal", "--enable-perlinterp", "--enable-rubyinterp", "--enable-python3interp", "--disable-gui", "--without-x", "--enable-luainterp", "--with-lua-prefix=#{Formula["lua"].opt_prefix}" system "make" # Parallel install could miss some symlinks # https://github.com/vim/vim/issues/1031 ENV.deparallelize # If stripping the binaries is enabled, vim will segfault with # statically-linked interpreters like ruby # https://github.com/vim/vim/issues/114 system "make", "install", "prefix=#{prefix}", "STRIP=#{which "true"}" bin.install_symlink "vim" => "vi" end test do (testpath/"commands.vim").write <<~VIM :python3 import vim; vim.current.buffer[0] = 'hello python3' :wq VIM system bin/"vim", "-T", "dumb", "-s", "commands.vim", "test.txt" assert_equal "hello python3", File.read("test.txt").chomp assert_match "+gettext", shell_output("#{bin}/vim --version") assert_match "+sodium", shell_output("#{bin}/vim --version") end end