homebrew-core/Formula/neovim.rb

118 lines
4.2 KiB
Ruby

class Neovim < Formula
desc "Ambitious Vim-fork focused on extensibility and agility"
homepage "https://neovim.io/"
url "https://github.com/neovim/neovim/archive/v0.7.0.tar.gz"
sha256 "792a9c55d5d5f4a5148d475847267df309d65fb20f05523f21c1319ea8a6c7df"
license "Apache-2.0"
head "https://github.com/neovim/neovim.git", branch: "master"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 arm64_monterey: "21da7566b9dc34a1a99a82e7a36e446b9dc17dad9bdf107d5fc46aeaea83879b"
sha256 arm64_big_sur: "81bddcbf646911e46bcf4853ec29c2eae48776a72c29e2b0f4d1ff36959be025"
sha256 monterey: "451c1643c6a01779c6443794c12ed41bc5629ab35059bea98ad54ea2459b4d48"
sha256 big_sur: "d234249fbe80c3a75cb563ff88d841cb9c1df9bbcc99b0a2e0981eb5acf26eca"
sha256 catalina: "137e5229d2322ad0f0662915db67cbb21e0581e3767b4648f6c7cbde51f8b54f"
sha256 x86_64_linux: "0676404738239fdb2d03a2af7c5c381240ad7beaa7b42038d8e2b11519357163"
end
depends_on "cmake" => :build
# Libtool is needed to build `libvterm`.
# Remove this dependency when we use the formula.
depends_on "libtool" => :build
depends_on "luarocks" => :build
depends_on "pkg-config" => :build
depends_on "gettext"
depends_on "libtermkey"
depends_on "libuv"
depends_on "luajit-openresty"
depends_on "luv"
depends_on "msgpack"
depends_on "tree-sitter"
depends_on "unibilium"
uses_from_macos "gperf" => :build
uses_from_macos "unzip" => :build
on_linux do
depends_on "libnsl"
end
# TODO: Use `libvterm` formula when the following is resolved:
# https://github.com/neovim/neovim/pull/16219
resource "libvterm" do
url "https://www.leonerd.org.uk/code/libvterm/libvterm-0.1.4.tar.gz"
sha256 "bc70349e95559c667672fc8c55b9527d9db9ada0fb80a3beda533418d782d3dd"
end
# Keep resources updated according to:
# https://github.com/neovim/neovim/blob/v#{version}/third-party/CMakeLists.txt
resource "mpack" do
url "https://github.com/libmpack/libmpack-lua/releases/download/1.0.8/libmpack-lua-1.0.8.tar.gz"
sha256 "ed6b1b4bbdb56f26241397c1e168a6b1672f284989303b150f7ea8d39d1bc9e9"
end
resource "lpeg" do
url "https://luarocks.org/manifests/gvvaughan/lpeg-1.0.2-1.src.rock"
sha256 "e0d0d687897f06588558168eeb1902ac41a11edd1b58f1aa61b99d0ea0abbfbc"
end
def install
resources.each do |r|
r.stage(buildpath/"deps-build/build/src"/r.name)
end
# The path separator for `LUA_PATH` and `LUA_CPATH` is `;`.
ENV.prepend "LUA_PATH", buildpath/"deps-build/share/lua/5.1/?.lua", ";"
ENV.prepend "LUA_CPATH", buildpath/"deps-build/lib/lua/5.1/?.so", ";"
# Don't clobber the default search path
ENV.append "LUA_PATH", ";", ";"
ENV.append "LUA_CPATH", ";", ";"
lua_path = "--lua-dir=#{Formula["luajit-openresty"].opt_prefix}"
cd "deps-build/build/src" do
%w[
mpack/mpack-1.0.8-0.rockspec
lpeg/lpeg-1.0.2-1.src.rock
].each do |rock|
dir, rock = rock.split("/")
cd dir do
output = Utils.safe_popen_read("luarocks", "unpack", lua_path, rock, "--tree=#{buildpath}/deps-build")
unpack_dir = output.split("\n")[-2]
cd unpack_dir do
system "luarocks", "make", lua_path, "--tree=#{buildpath}/deps-build"
end
end
end
# Build libvterm. Remove when we use the formula.
cd "libvterm" do
system "make", "install", "PREFIX=#{buildpath}/deps-build", "LDFLAGS=-static #{ENV.ldflags}"
ENV.prepend_path "PKG_CONFIG_PATH", buildpath/"deps-build/lib/pkgconfig"
end
end
system "cmake", "-S", ".", "-B", "build",
"-DLIBLUV_LIBRARY=#{Formula["luv"].opt_lib/shared_library("libluv")}",
*std_cmake_args
# Patch out references to Homebrew shims
inreplace "build/config/auto/versiondef.h", Superenv.shims_path/ENV.cc, ENV.cc
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
test do
(testpath/"test.txt").write("Hello World from Vim!!")
system bin/"nvim", "--headless", "-i", "NONE", "-u", "NONE",
"+s/Vim/Neovim/g", "+wq", "test.txt"
assert_equal "Hello World from Neovim!!", (testpath/"test.txt").read.chomp
end
end