fix(lsp): force lsp-zig-download-url-format to change

Can't change the variable after lsp-zig loads because its used when it's
loaded. Can't set it before lsp-zig loads because it's a
constant (resetting its value). Thank god it uses a (non-inlined)
function to build that URL, so we have an easy target to advise.

Fix: #7970
Amend: 93dfb0acfb
Amend: bc5a8ec3fa
Amend: 7bb5df4cd4
This commit is contained in:
Henrik Lissner 2024-07-30 00:48:42 -04:00
parent 93dfb0acfb
commit 85b7b6151b
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -43,9 +43,20 @@ Can be a list of backends; accepts any value `company-backends' accepts.")
(when (modulep! :config default +bindings)
(setq lsp-keymap-prefix nil))
;; REVIEW: Remove when zigtools/zls#1879 is resolved.
(unless (featurep :system 'windows)
(setq lsp-zig-download-url-format "https://github.com/zigtools/zls/releases/latest/download/zls-%s-%s.tar.xz"))
;; HACK: Frustratingly enough, the value of `lsp-zig-download-url-format' is
;; used immediately while the lsp-zig package is loading, so changing it
;; *after* lsp-zig makes no difference. What's worse, the variable is a
;; constant, so we can't change it *before* the package is loaded either!
;; Thank god a (non-inlined) function is used to build the URL, so we have
;; something to advise.
;; REVIEW: Remove when zigtools/zls#1879 is resolved.
(defadvice! +lsp--use-correct-zls-download-url-a (fn &rest _)
"See zigtools/zls#1879."
:around #'lsp-zig--zls-url
(let ((lsp-zig-download-url-format
"https://github.com/zigtools/zls/releases/latest/download/zls-%s-%s.tar.xz"))
(apply fn args))))
:config
(add-to-list 'doom-debug-variables 'lsp-log-io)