Skip to content

Commit 0a56753

Browse files
authored
fix: get correct URL for lua-language-server release artifact on Windows (#5006)
* fix: get correct URL for `lua-language-server` release artifact on Windows Currently, `lua-language-server` installs are done by getting the URLs to release artifacts by matching the release API response to a hardcoded string consisting of `platform-architecture.<ARCHIVE_FORMAT>`, with the `ARCHIVE_FORMAT` itself being hardcoded to always be `.tar.gz`. Currently, `lua-language-server` releases archives for Windows within a `.zip` archive instead of `.tar.gz`, which causes the logic to fail on Windows and send over a `nil` instead to the download function. Instead of fixing it by updating the hardcoded values, this opts to make it more dynamic and try to figure out what symbol to send over to the decompression argument from the downloaded archive's filename, as well as to only use the platform string to determine which link to find and follow to download the LSP from, sans archive format suffix. This SHOULD hold better moving forward, barring any strange issues where e.g. the release has checksums listed at the top with the `platform-architecture` string embedded in the filename, but this isn't guaranteed to be stable forever moving forward unless there's some consensus around HOW to find artifacts for a particular configuration in a stable manner. * don't modify match data This only cares about whether or not it matches and won't do anything with the resulting match data. * condense parentheses
1 parent 8465450 commit 0a56753

1 file changed

Lines changed: 34 additions & 28 deletions

File tree

clients/lsp-lua.el

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -553,34 +553,40 @@ and `../lib` ,exclude `../lib/temp`.
553553
"Download the latest version of lua-language-server and extract it to
554554
`lsp-lua-language-server-install-dir'."
555555
(ignore client update?)
556-
(let ((store-path (expand-file-name "lua-language-server-github" lsp-clients-lua-language-server-install-dir)))
557-
(lsp-download-install
558-
(lambda (&rest _)
559-
(set-file-modes lsp-clients-lua-language-server-bin #o0700)
560-
(funcall callback))
561-
error-callback
562-
:url (lsp--find-latest-gh-release-url
563-
"https://api.github.com/repos/LuaLS/lua-language-server/releases/latest"
564-
(format "%s%s.tar.gz"
565-
(pcase system-type
566-
('gnu/linux
567-
(pcase (lsp-resolve-value lsp--system-arch)
568-
('x64 "linux-x64")
569-
('arm64 "linux-arm64")))
570-
('darwin
571-
(pcase (lsp-resolve-value lsp--system-arch)
572-
('x64 "darwin-x64")
573-
('arm64 "darwin-arm64")))
574-
('windows-nt
575-
(pcase (lsp-resolve-value lsp--system-arch)
576-
('x64 "win32-x64")
577-
('arm64 "win32-ia32")))
578-
(_
579-
(pcase (lsp-resolve-value lsp--system-arch)
580-
('x64 "linux-x64"))))
581-
(if lsp-lua-prefer-musl "-musl" "")))
582-
:store-path store-path
583-
:decompress (pcase system-type ('windows-nt :zip) (_ :targz)))))
556+
(let ((store-path (expand-file-name "lua-language-server-github" lsp-clients-lua-language-server-install-dir))
557+
(url (lsp--find-latest-gh-release-url
558+
"https://api.github.com/repos/LuaLS/lua-language-server/releases/latest"
559+
(format "%s%s"
560+
(pcase system-type
561+
('gnu/linux
562+
(pcase (lsp-resolve-value lsp--system-arch)
563+
('x64 "linux-x64")
564+
('arm64 "linux-arm64")))
565+
('darwin
566+
(pcase (lsp-resolve-value lsp--system-arch)
567+
('x64 "darwin-x64")
568+
('arm64 "darwin-arm64")))
569+
('windows-nt
570+
(pcase (lsp-resolve-value lsp--system-arch)
571+
('x64 "win32-x64")
572+
('arm64 "win32-ia32")))
573+
(_
574+
(pcase (lsp-resolve-value lsp--system-arch)
575+
('x64 "linux-x64"))))
576+
(if lsp-lua-prefer-musl "-musl" "")))))
577+
(let ((decompress (if (string-match-p "\.zip$" url)
578+
(progn :zip)
579+
(if (string-match-p "\.tar.gz$" url)
580+
(progn :targz)
581+
:gzip))))
582+
(lsp-download-install
583+
(lambda (&rest _)
584+
(set-file-modes lsp-clients-lua-language-server-bin #o0700)
585+
(funcall callback))
586+
error-callback
587+
:url url
588+
:store-path store-path
589+
:decompress decompress))))
584590

585591
(lsp-register-client
586592
(make-lsp-client

0 commit comments

Comments
 (0)