From 8e4acd736b946feb8037dc7c4b941232d7798066 Mon Sep 17 00:00:00 2001 From: tamakiii Date: Wed, 28 Oct 2020 21:41:36 +0900 Subject: [PATCH] copy vim.rb from homebrew/homebrew-core --- Formula/vim.rb | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Formula/vim.rb diff --git a/Formula/vim.rb b/Formula/vim.rb new file mode 100644 index 0000000..be493ec --- /dev/null +++ b/Formula/vim.rb @@ -0,0 +1,80 @@ +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/v8.2.1900.tar.gz" + sha256 "28b734e9f6d4ed0eaf5b2a2c7528798e6b66243c9665253cd223c03572fde4bf" + license "Vim" + head "https://github.com/vim/vim.git" + + bottle do + sha256 "9fee8d0c97fae8a67ed27636e687760e32b58dbecb658a138010ace28ff241a6" => :catalina + sha256 "8e0b7559bd093adf61a5b75a8ce61962976f9fe94af9a822c76d10d9768c8a47" => :mojave + sha256 "57f2fddfda635fafc3694e95147c3d31ee369add4bd26a0e0d66847d5aae8c7c" => :high_sierra + end + + depends_on "gettext" + depends_on "lua" + depends_on "perl" + depends_on "python@3.9" + depends_on "ruby" + + uses_from_macos "ncurses" + + 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.9"].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", + "--enable-gui=no", + "--without-x", + "--enable-luainterp", + "--with-lua-prefix=#{Formula["lua"].opt_prefix}", + "--enable-fail-if-missing" + 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