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.6.1.tar.gz"
sha256 "dd882c21a52e5999f656cae3f336b5fc702d52addd4d9b5cd3dc39cfff35e864"
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: "cb57c0fb2aca62d06e77176c7da2acae54c461293d93f66ac2f70cf5f00caf6e"
sha256 arm64_big_sur: "1129c801c8e54eed760f10ae7ac6bcc2b5b9c3f9c55b3d40e2190546d7ffae9c"
sha256 monterey: "3d5fad96914b500a9bf118d3cdbfa808639dbe003fa90f7b9230e5efa25a8a97"
sha256 big_sur: "17d3d6e1b761650c2b4f623808d95d6884eee3fcc59ee47f75d2a777b3589ced"
sha256 catalina: "8a39c2142e8f6d6335d83544af66c8e03599e50cd9a357257b777e6c48dbd089"
sha256 x86_64_linux: "3287fadd7e5d8dae73b5055f6ae5f85391a4b8b29a6ab3fbbfbd4ca8f828f841"
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 "http://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