Skip to content

Commit 962f215

Browse files
committed
Fix installing fsautocomplete process
- Use cache for avoiding getting latest version - Fix version checking - Don't always install fsautocomplete
1 parent cfd3f88 commit 962f215

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

eglot-fsharp.el

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@
6464

6565
(defun eglot-fsharp--latest-version ()
6666
"Return latest fsautocomplete.exe version."
67-
(let* ((json (with-temp-buffer (url-insert-file-contents "https://azuresearch-usnc.nuget.org/query?q=fsautocomplete&prerelease=false&packageType=DotnetTool")
68-
(json-parse-buffer)))
69-
(versions (gethash "versions" (aref (gethash "data" json) 0))))
70-
(gethash "version" (aref versions (1- (length versions))))))
67+
(or eglot-fsharp--latest-version
68+
(let* ((json (with-temp-buffer (url-insert-file-contents "https://azuresearch-usnc.nuget.org/query?q=fsautocomplete&prerelease=false&packageType=DotnetTool")
69+
(json-parse-buffer)))
70+
(versions (gethash "versions" (aref (gethash "data" json) 0))))
71+
(setq eglot-fsharp--latest-version (gethash "version" (aref versions (1- (length versions))))))))
7172

7273
(defun eglot-fsharp--installed-version ()
7374
"Return version string of fsautocomplete."
@@ -77,10 +78,10 @@
7778
(defun eglot-fsharp-current-version-p (version)
7879
"Return t if the installation is not outdated."
7980
(when (file-exists-p (eglot-fsharp--path-to-server))
80-
(if (eq version 'latest)
81+
(if (eq eglot-fsharp-server-version 'latest)
8182
(equal (eglot-fsharp--latest-version)
8283
(eglot-fsharp--installed-version))
83-
(equal eglot-fsharp-server-version (eglot-fsharp--installed-version)))))
84+
(equal version (eglot-fsharp--installed-version)))))
8485

8586
(defun eglot-fsharp--install-core (version)
8687
"Download and install fsautocomplete as a dotnet tool at version VERSION in `eglot-fsharp-server-install-dir'."
@@ -96,12 +97,12 @@
9697
nil "tool" "uninstall"
9798
"fsautocomplete" "--tool-path"
9899
default-directory))
99-
(error "'dotnet tool uninstall fsautocomplete --tool-path %s' failed" default-directory))))
100-
(unless (zerop (call-process "dotnet" nil `(nil ,stderr-file) nil
101-
"tool" "install" "fsautocomplete"
102-
"--tool-path" default-directory "--version"
103-
version))
104-
(error "'dotnet tool install fsautocomplete --tool-path %s --version %s' failed" default-directory version)))
100+
(error "'dotnet tool uninstall fsautocomplete --tool-path %s' failed" default-directory)))
101+
(unless (zerop (call-process "dotnet" nil `(nil ,stderr-file) nil
102+
"tool" "install" "fsautocomplete"
103+
"--tool-path" default-directory "--version"
104+
version))
105+
(error "'dotnet tool install fsautocomplete --tool-path %s --version %s' failed" default-directory version))))
105106
(error
106107
(let ((stderr (with-temp-buffer
107108
(insert-file-contents stderr-file)

0 commit comments

Comments
 (0)