homebrew-core/Formula/vim.rb

93 lines
3.9 KiB
Ruby

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/v9.0.0900.tar.gz"
sha256 "155d2da4b59769b5929a9d64bd8463cc7f8e4a7515a02806c9d699fedeaa8661"
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 page of tags on GitHub (to minimize data transfer).
livecheck do
url "https://github.com/vim/vim/tags"
regex(%r{href=["']?[^"' >]*?/tag/v?(\d+(?:\.\d+)+)["' >]}i)
strategy :page_match
end
bottle do
sha256 arm64_ventura: "c28b7132d1ccdbafbdf97a22d9ebeb95cc90f65953e089413b66876b9ec00c5e"
sha256 arm64_monterey: "570bcfb42040ad5708e10b9a5e23da72f195a1e6678cd0d35558590989e030a7"
sha256 arm64_big_sur: "ccd541e6d3c62182abb979bef330b7162178d61d77485321090d203b2fc99d75"
sha256 ventura: "da62f78d5cd9480e257177c30d0014ac48f2a2ada13fb27bdddd82d9fe2ea59f"
sha256 monterey: "15758631168c4de0c4fe6f2bf56bc37038a766f39b51deb45df7bfe9c74f9eb5"
sha256 big_sur: "2c3180429a66ce434b119c07844fd9123aefbd97ca1f0d5097a97b012495a7ac"
sha256 catalina: "2714d1fed3edbd10a4805f5d4410d32da5045e2c0ac13a3a89c51508084755a3"
sha256 x86_64_linux: "2c466fafe6941c7c55ec365dd36bd8e10fadb0952e03d028568bac13cb9c5b1b"
end
depends_on "gettext"
depends_on "lua"
depends_on "ncurses"
depends_on "perl"
depends_on "python@3.10"
depends_on "ruby"
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.10"].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")
# 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 <<~EOS
:python3 import vim; vim.current.buffer[0] = 'hello python3'
:wq
EOS
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")
end
end