compatibility fix: neovim 0.4 => sniprun v0.4.9
@@ -26,19 +26,20 @@ get_latest_release() {
download() {
# command -v curl >/dev/null &&
# curl --fail --location "$1" --output target/release/sniprun
+ echo "Downloading" $1
rm -rf download_dir
mkdir -p download_dir
cd download_dir
- curl -s https://api.github.com/repos/michaelb/sniprun/releases/latest | grep "sniprun" | cut -d ":" -f 2,3 | tr -d \" | wget -qi -
+ # curl -s https://api.github.com/repos/michaelb/sniprun/releases/$1 | grep "sniprun" | cut -d ":" -f 2,3 | tr -d \" | wget -qi -
+ wget -q https://github.com/michaelb/sniprun/releases/download/v0.4.9/sniprun
mv -f sniprun ../target/release/
cd ..
}
fetch_prebuilt_binary() {
- echo "Downloading binary.."
mkdir -p target/release
- if (download "$url"); then
+ if (download $1); then
chmod a+x target/release/sniprun
echo "Done"
return
@@ -49,7 +50,7 @@ fetch_prebuilt_binary() {
arch=$(uname)
if [ $arch != "Linux" ]; then
- echo "Warning, sniprun needs Linux to work properly! Any behaviour from this point is not tested"
+ echo "Warning: Doesn't look like you are on Linux. Sniprun is not tested on Mac and will not work on windows"
fi
remote_version=v$(get_latest_release)
@@ -58,10 +59,20 @@ if [ $force_build ]; then
echo "Always compiling the latest commit (most bleeding-edge option)"
cargo_build
else
+
+ tag_to_fetch=$remote_version
+ neovim_version=$(nvim --version | head -n 1 | cut -d . -f 2) # 4 -> neovim 0.4.x
+ if [ $neovim_version == "4" ]; then
+ echo "Sniprun 0.4.9 is the highest version supported on neovim 0.4.x"
+ git reset --hard v0.4.9
+ tag_to_fetch="v0.4.9"
+ fi
+
+
#check if release is up to date
if [ $local_version == $remote_version ]; then
echo "Trying to get a up-to-date precompiled binary"
- fetch_prebuilt_binary
+ fetch_prebuilt_binary $tag_to_fetch
success=$?
else
echo "Release version is not up to date, building from source"
@@ -72,7 +83,7 @@ else
# if nothing succeeded
if [ success == 1 ]; then
echo "Could not build (missing rust/cargo toolchain?). Getting an out-of-date release if available"
- fetch_prebuilt_binary # get an older release
+ fetch_prebuilt_binary $tag_to_fetch # get an older release
fi
fi
