-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix installing fsautocomplete process #323
base: master
Are you sure you want to change the base?
Conversation
syohex
commented
Nov 8, 2022
- Use cache for avoiding getting latest version
- Fix version checking
- Don't always install fsautocomplete
- Use cache for avoiding getting latest version - Fix version checking - Don't always install fsautocomplete
(or eglot-fsharp--latest-version | ||
(let* ((json (with-temp-buffer (url-insert-file-contents "https://azuresearch-usnc.nuget.org/query?q=fsautocomplete&prerelease=false&packageType=DotnetTool") | ||
(json-parse-buffer))) | ||
(versions (gethash "versions" (aref (gethash "data" json) 0)))) | ||
(setq eglot-fsharp--latest-version (gethash "version" (aref versions (1- (length versions)))))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use cache.
emacs-fsharp-mode/eglot-fsharp.el
Line 63 in 962f215
(defvar eglot-fsharp--latest-version nil "Latest fsautocomplete.exe version string.") |
The cache variable is declared but it is never used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of (eglot-fsharp--latest-version)
is to ALWAYS return the exact version string, so we can compare the version string of the locally installed version string and prevent downloading the nuget artefact.
Maybe I should document this better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juergenhoetzel Should I remove cache variable ? Comparison is already implemented. Sorry I didn't catch what you mean.
emacs-fsharp-mode/eglot-fsharp.el
Lines 77 to 83 in f887309
(defun eglot-fsharp-current-version-p (version) | |
"Return t if the installation is not outdated." | |
(when (file-exists-p (eglot-fsharp--path-to-server)) | |
(if (eq version 'latest) | |
(equal (eglot-fsharp--latest-version) | |
(eglot-fsharp--installed-version)) | |
(equal eglot-fsharp-server-version (eglot-fsharp--installed-version))))) |
(if (eq version 'latest) | ||
(if (eq eglot-fsharp-server-version 'latest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version
argument is string type, so it is never 'latest
.
(equal (eglot-fsharp--latest-version) | ||
(eglot-fsharp--installed-version)) | ||
(equal eglot-fsharp-server-version (eglot-fsharp--installed-version))))) | ||
(equal version (eglot-fsharp--installed-version))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eglot-fsharp-server-version
may be symbol. So version
should be used here.
(unless (zerop (call-process "dotnet" nil `(nil ,stderr-file) nil | ||
"tool" "install" "fsautocomplete" | ||
"--tool-path" default-directory "--version" | ||
version)) | ||
(error "'dotnet tool install fsautocomplete --tool-path %s --version %s' failed" default-directory version))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code block is always evaluated even if desired version is installed. I suppose if this expression should be evaluated if (eglot-fsharp-current-version-p version)
is nil