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.1950.tar.gz" sha256 "fca27c4cbb9e265611a89c5d6e8d76e93845ea1a9ba39ba5a589a2ba7e973e7b" 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: "5aa3705ed503ae6cb0210b2d0d82a4c14438cf23acda24dfdaf0e2c09fe7be59" sha256 arm64_sequoia: "762efcec5cc21d6dd70f96c6642ba405249b14ca17529de3b77354017160aef7" sha256 arm64_sonoma: "f3240ac71906912a9e36c8548a55c695ab089b83a639911931507d9c0c668db1" sha256 sonoma: "1d732680512733832989c39ce97994d8bc8079fe90e9b5f6cf376c6992a88837" sha256 arm64_linux: "af3266d571cd8213bd6c92e9559b3f1006b704f1456846aa859708fba9606820" sha256 x86_64_linux: "66dfe9c7dc12308bc42cc33ef80f6935ac032e1312b335668e0eca876fc9300d" end depends_on "gettext" depends_on "libsodium" depends_on "lua" depends_on "ncurses" depends_on "python@3.14" depends_on "ruby" uses_from_macos "perl" 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