-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
/
Copy pathneovim.rb
140 lines (116 loc) · 5.38 KB
/
neovim.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
class Neovim < Formula
desc "Ambitious Vim-fork focused on extensibility and agility"
homepage "https://neovim.io/"
license "Apache-2.0"
head "https://github.com/neovim/neovim.git", branch: "master"
stable do
url "https://github.com/neovim/neovim/archive/refs/tags/v0.11.1.tar.gz"
sha256 "ffe7f9a7633ed895ff6adb1039af7516cd6453715c8889ad844b6fa39c3df443"
# Keep resources updated according to:
# https://github.com/neovim/neovim/blob/v#{version}/cmake.deps/CMakeLists.txt
# TODO: Consider shipping these as separate formulae instead. See discussion at
# https://github.com/orgs/Homebrew/discussions/3611
# NOTE: The `install` method assumes that the parser name follows the final `-`.
# Please name the resources accordingly.
resource "tree-sitter-c" do
url "https://github.com/tree-sitter/tree-sitter-c/archive/refs/tags/v0.23.4.tar.gz"
sha256 "b66c5043e26d84e5f17a059af71b157bcf202221069ed220aa1696d7d1d28a7a"
end
resource "tree-sitter-lua" do
url "https://github.com/tree-sitter-grammars/tree-sitter-lua/archive/refs/tags/v0.3.0.tar.gz"
sha256 "a34cc70abfd8d2d4b0fabf01403ea05f848e1a4bc37d8a4bfea7164657b35d31"
end
resource "tree-sitter-vim" do
url "https://github.com/tree-sitter-grammars/tree-sitter-vim/archive/refs/tags/v0.5.0.tar.gz"
sha256 "90019d12d2da0751c027124f27f5335babf069a050457adaed53693b5e9cf10a"
end
resource "tree-sitter-vimdoc" do
url "https://github.com/neovim/tree-sitter-vimdoc/archive/refs/tags/v3.0.1.tar.gz"
sha256 "76b65e5bee9ff78eb21256619b1995aac4d80f252c19e1c710a4839481ded09e"
end
resource "tree-sitter-query" do
url "https://github.com/nvim-treesitter/tree-sitter-query/archive/refs/tags/v0.5.1.tar.gz"
sha256 "fe8c712880a529d454347cd4c58336ac2db22243bae5055bdb5844fb3ea56192"
end
resource "tree-sitter-markdown" do
url "https://github.com/tree-sitter-grammars/tree-sitter-markdown/archive/refs/tags/v0.4.1.tar.gz"
sha256 "e0fdb2dca1eb3063940122e1475c9c2b069062a638c95939e374c5427eddee9f"
end
end
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 arm64_sequoia: "371e99be7b1d20d76b2d08615156d1d2c374526baf54dffb2245a0e65eaca68c"
sha256 arm64_sonoma: "ad9124bcbc7a972899a91ff64788e8c05bd304fc48a2f178afa398318ac255e4"
sha256 arm64_ventura: "2bf780725a36d678dd6d687380db074c6ffa34fd90df7abb0afc8d119a9fafa3"
sha256 sonoma: "5ddbcda1bba79b13591960a797bebae27834c332ac6d69a29ce5e589a8a36a09"
sha256 ventura: "bc08b7cfa6822335edcc514f55fab5a63be316bee1b68360f965461692579f08"
sha256 arm64_linux: "e4fc50b684a3f3fcd71e63b2050ea41eb3817abbfed7933ebcca188f83beace6"
sha256 x86_64_linux: "c5d732c24b1252be3bbe98e44cddd5237a7dea2e94f9c712e4fe9764008655e3"
end
depends_on "cmake" => :build
depends_on "gettext"
depends_on "libuv"
depends_on "lpeg"
depends_on "luajit"
depends_on "luv"
depends_on "tree-sitter"
depends_on "unibilium"
depends_on "utf8proc"
def install
if build.head?
cmake_deps = (buildpath/"cmake.deps/deps.txt").read.lines
cmake_deps.each do |line|
next unless line.match?(/TREESITTER_[^_]+_URL/)
parser, parser_url = line.split
parser_name = parser.delete_suffix("_URL")
parser_sha256 = cmake_deps.find { |l| l.include?("#{parser_name}_SHA256") }.split.last
parser_name = parser_name.downcase.tr("_", "-")
resource parser_name do
url parser_url
sha256 parser_sha256
end
end
end
resources.each do |r|
source_directory = buildpath/"deps-build/build/src"/r.name
build_directory = buildpath/"deps-build/build"/r.name
parser_name = r.name.split("-").last
cmakelists = case parser_name
when "markdown" then "MarkdownParserCMakeLists.txt"
else "TreesitterParserCMakeLists.txt"
end
r.stage(source_directory)
cp buildpath/"cmake.deps/cmake"/cmakelists, source_directory/"CMakeLists.txt"
system "cmake", "-S", source_directory, "-B", build_directory, "-DPARSERLANG=#{parser_name}", *std_cmake_args
system "cmake", "--build", build_directory
system "cmake", "--install", build_directory
end
# Point system locations inside `HOMEBREW_PREFIX`.
inreplace "src/nvim/os/stdpaths.c" do |s|
s.gsub! "/etc/xdg/", "#{etc}/xdg/:\\0"
if HOMEBREW_PREFIX.to_s != HOMEBREW_DEFAULT_PREFIX
s.gsub! "/usr/local/share/:/usr/share/", "#{HOMEBREW_PREFIX}/share/:\\0"
end
end
# Replace `-dirty` suffix in `--version` output with `-Homebrew`.
inreplace "cmake/GenerateVersion.cmake", "--dirty", "--dirty=-Homebrew"
args = [
"-DLUV_LIBRARY=#{Formula["luv"].opt_lib/shared_library("libluv")}",
"-DLIBUV_LIBRARY=#{Formula["libuv"].opt_lib/shared_library("libuv")}",
"-DLPEG_LIBRARY=#{Formula["lpeg"].opt_lib/shared_library("liblpeg")}",
]
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
test do
refute_match "dirty", shell_output("#{bin}/nvim --version")
(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