Created
February 23, 2025 19:04
-
-
Save m87h/e453d75a89f438c86c9987c710c6c56c to your computer and use it in GitHub Desktop.
vim-lsp-settings-nightly-zig.diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --color -ur a/installer/install-zls.sh b/installer/install-zls.sh | |
--- a/installer/install-zls.sh 2025-02-23 20:02:19 | |
+++ b/installer/install-zls.sh 2025-02-23 20:02:36 | |
@@ -2,8 +2,34 @@ | |
set -e | |
+zls_for_zig_version() { | |
+ git log -G minimum_zig_version --format=%H build.zig.zon | while read commit; do | |
+ if git show $commit:build.zig.zon | awk -v major=$1 -v minor=$2 -v patch=$3 -v rev=$4 \ | |
+ 'match($0, /minimum_zig_version = ".+"/) { \ | |
+ split(substr($0, RSTART+23, RLENGTH-24), v, "[.\\-+]"); \ | |
+ if (v[1] > major || v[1] == major && v[2] > minor || v[1] == major && v[2] == minor && v[3] > patch || rev != "" && v[1] == major && v[2] == minor && v[3] == patch && v[5] > rev) exit 1\ | |
+ }'; then | |
+ echo $commit | |
+ break | |
+ fi | |
+ done | |
+} | |
+ | |
+IFS=.-+ read -r major minor patch _ rev _ <<V | |
+$(zig version) | |
+V | |
+unset IFS | |
+ | |
git clone https://github.com/zigtools/zls . | |
-git checkout "refs/tags/$(git tag | grep "^$(zig version | sed -r 's/\.[0-9]+$//')")" | |
+ | |
+zls=$(zls_for_zig_version $major $minor $patch $rev) | |
+ | |
+# fall back on previous behavior (mainly for older versions) | |
+if [ -z "$zls" ]; then | |
+ zls="refs/tags/$(git tag | grep "^$major.$minor.")" | |
+fi | |
+ | |
+git checkout "$zls" | |
git submodule update --init --recursive | |
zig build | |
mv zig-out/bin/zls . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment