dot-files/dot_local/bin/executable_install-lua-language-server
Buddy 6b55be7df2 fix: support arm64 in install-lua-language-server
get_arch() only handled x86_64, so arm64 machines failed with
"unsupported architecture: arm64". Also switch the bin symlink to a
wrapper script: lua-language-server locates main.lua relative to its
own unresolved argv[0], so launching it through a symlinked executable
(rather than a symlinked directory) made it fail to find main.lua.
2026-09-14 09:27:02 -07:00

41 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# shellcheck disable=SC1091
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
main() (
APP=lua-language-server
VERSION=${VERSION:-3.19.1}
DEST=${XDG_DATA_HOME}/apps/releases/${APP}
URL=https://github.com/LuaLS/lua-language-server/releases/download/${VERSION}/lua-language-server-${VERSION}-$(get_os)-$(get_arch).tar.gz
extract_tarball "${URL}" "${DEST}/${VERSION}"
set_current_link "${DEST}" "${VERSION}"
# lua-language-server locates main.lua next to its own argv[0], without
# resolving symlinks, so it can't be launched through a symlinked
# executable (only a symlinked directory in the path works). Use a
# wrapper script instead of set_link.
cat >"${XDG_BIN_HOME}/lua-language-server" <<EOF
#!/usr/bin/env bash
exec "${DEST}/current/bin/lua-language-server" "\$@"
EOF
chmod +x "${XDG_BIN_HOME}/lua-language-server"
)
get_arch() (
case $(uname -m) in
x86_64*) echo x64 ;;
arm64*) echo arm64 ;;
aarch64*) echo arm64 ;;
*)
echo >&2 "unsupported architecture: $(uname -m)"
exit 1
;;
esac
)
main "$@"