From 993ffee2e714eba4d39529b7b7d5ee9c2541f02d Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Tue, 14 May 2024 17:38:25 +0200 Subject: [PATCH 1/3] Allow to use "fsautocomplete" from the global tool-path. Setting `eglot-fsharp-server-install-dir' to nil disables the custom "~/.emacs.d/FsAutoComplete/netcore/" tool path. Fixes #341 --- eglot-fsharp.el | 51 +++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/eglot-fsharp.el b/eglot-fsharp.el index bce6c81..bcb820e 100644 --- a/eglot-fsharp.el +++ b/eglot-fsharp.el @@ -1,6 +1,6 @@ ;;; eglot-fsharp.el --- fsharp-mode eglot integration -*- lexical-binding: t; -*- -;; Copyright (C) 2019-2023 Jürgen Hötzel +;; Copyright (C) 2019-2024 Jürgen Hötzel ;; Author: Jürgen Hötzel ;; Package-Requires: ((emacs "27.1") (eglot "1.4") (fsharp-mode "1.10") (jsonrpc "1.0.14")) @@ -41,7 +41,7 @@ "Install directory for FsAutoComplete." :group 'eglot-fsharp :risky t - :type 'directory) + :type '(choice directory (const :tag "Use dotnet default for tool-path" nil))) (defcustom eglot-fsharp-server-version 'latest "FsAutoComplete version to install or update." @@ -63,7 +63,7 @@ :abstractClassStubGenerationObjectIdentifier "this" :addFsiWatcher nil :codeLenses (:references (:enabled t) - :signature (:enabled t)) + :signature (:enabled t)) :disableFailedProjectNotifications nil :dotnetRoot "" :enableAdaptiveLspServer t @@ -120,7 +120,10 @@ (defun eglot-fsharp--path-to-server () "Return FsAutoComplete path." - (file-truename (concat eglot-fsharp-server-install-dir "netcore/fsautocomplete" (if (eq system-type 'windows-nt) ".exe" "")))) + (let ((base (if eglot-fsharp-server-install-dir + (concat eglot-fsharp-server-install-dir "netcore/") + "~/.dotnet/tools/"))) + (expand-file-name (concat base "fsautocomplete" (if (eq system-type 'windows-nt) ".exe" ""))))) ;; cache to prevent repetitive queries (defvar eglot-fsharp--latest-version nil "Latest fsautocomplete.exe version string.") @@ -135,7 +138,9 @@ (defun eglot-fsharp--installed-version () "Return version string of fsautocomplete." (with-temp-buffer - (process-file "dotnet" nil t nil "tool" "list" "--tool-path" (file-name-directory (eglot-fsharp--path-to-server))) + (if eglot-fsharp-server-install-dir + (process-file "dotnet" nil t nil "tool" "list" "--tool-path" (file-name-directory (eglot-fsharp--path-to-server))) + (process-file "dotnet" nil t nil "tool" "list" "-g")) (goto-char (point-min)) (when (search-forward-regexp "^fsautocomplete[[:space:]]+\\([0-9\.]*\\)[[:space:]]+" nil t) (match-string 1)))) @@ -150,35 +155,35 @@ (let* ((default-directory (concat (file-remote-p default-directory) (file-name-directory (eglot-fsharp--path-to-server)))) (stderr-file (make-temp-file "dotnet_stderr")) - (local-tool-path (or (file-remote-p default-directory 'localname) default-directory))) + (local-tool-path (or (file-remote-p default-directory 'localname) default-directory)) + (process-file-uninstall-args (if eglot-fsharp-server-install-dir + (list "dotnet" nil `(nil ,stderr-file) nil "tool" "uninstall" "fsautocomplete" "--tool-path" local-tool-path) + (list "dotnet" nil `(nil ,stderr-file) nil "tool" "uninstall" "-g" "fsautocomplete"))) + (process-file-install-args (if eglot-fsharp-server-install-dir + (list "dotnet" nil `(nil ,stderr-file) nil "tool" "install" "fsautocomplete" "--tool-path" local-tool-path "--version" version) + (list "dotnet" nil `(nil ,stderr-file) nil "tool" "install" "fsautocomplete" "-g" "--version" version)))) + (make-directory default-directory t) (condition-case err (progn - (unless (eglot-fsharp-current-version-p version) - (message "Installing fsautocomplete version %s" version) - (when (file-exists-p (concat (file-remote-p default-directory) - (eglot-fsharp--path-to-server))) - (unless (zerop (process-file "dotnet" nil `(nil - ,stderr-file) - nil "tool" "uninstall" - "fsautocomplete" "--tool-path" - local-tool-path)) - (error "'dotnet tool uninstall fsautocomplete --tool-path %s' failed" default-directory)))) - (unless (zerop (process-file "dotnet" nil `(nil ,stderr-file) nil - "tool" "install" "fsautocomplete" - "--tool-path" local-tool-path "--version" - version)) + (unless (or (eglot-fsharp-current-version-p version) (not (eglot-fsharp--installed-version))) + (message "Uninstalling fsautocomplete version %s" (eglot-fsharp--installed-version)) + (unless (zerop (apply #'process-file process-file-uninstall-args)) + (error "'dotnet tool uninstall fsautocomplete ... failed"))) + (unless (zerop (apply #'process-file process-file-install-args)) (error "'dotnet tool install fsautocomplete --tool-path %s --version %s' failed" default-directory version))) (error (let ((stderr (with-temp-buffer (insert-file-contents stderr-file) (buffer-string)))) (delete-file stderr-file) - (signal (car err) (format "%s: %s" (cdr err) stderr))))))) + (signal (car err) (format "%s: %s" (cdr err) stderr))))) + (message "Installed fsautocomplete to %s" (eglot-fsharp--path-to-server)))) (defun eglot-fsharp--maybe-install (&optional version) "Downloads F# compiler service, and install in `eglot-fsharp-server-install-dir'." - (make-directory (concat (file-remote-p default-directory) - (file-name-directory (eglot-fsharp--path-to-server))) t) + (unless eglot-fsharp-server-install-dir + (make-directory (concat (file-remote-p default-directory) + (file-name-directory (eglot-fsharp--path-to-server))) t)) (let* ((version (or version (if (eq eglot-fsharp-server-version 'latest) (eglot-fsharp--latest-version) eglot-fsharp-server-version)))) From 65feb1ef5d662af57f268484dbb9f35179190a5a Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Tue, 14 May 2024 21:11:19 +0200 Subject: [PATCH 2/3] Increase default test timeout --- test/eglot-fsharp-integration-util.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/eglot-fsharp-integration-util.el b/test/eglot-fsharp-integration-util.el index c1fbf83..7d16f52 100644 --- a/test/eglot-fsharp-integration-util.el +++ b/test/eglot-fsharp-integration-util.el @@ -62,7 +62,7 @@ (find-file-noselect file)) (defun eglot-fsharp--tests-connect (&optional timeout) - (let* ((timeout (or timeout 10)) + (let* ((timeout (or timeout 30)) (eglot-sync-connect t) (eglot-connect-timeout timeout)) (apply #'eglot--connect (eglot--guess-contact)))) From cfc7047fc1acec702de0c10cad12ab89a972230a Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Tue, 14 May 2024 21:16:41 +0200 Subject: [PATCH 3/3] Tests: Update dotnet version / Add new Emacs release --- .github/workflows/test.yml | 90 +++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f10cef1..20fc682 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,58 +12,58 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - dotnet: [6.0.200] + dotnet: [8.0.x] emacs_version: - 27.2 - - 28.1 - 28.2 + - 29.3 - snapshot steps: - - uses: purcell/setup-emacs@master - with: - version: ${{ matrix.emacs_version }} - - uses: actions/setup-dotnet@v1 - with: - dotnet-version: ${{ matrix.dotnet }} - - uses: actions/checkout@v2 - - name: Install Eldev - run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh - - name: Show dotnet sdks - run: dotnet --list-sdks - - name: Show dotnet version - run: dotnet --info - - name: Test - run: | - echo "Archives:" - eldev archives - echo "Dependencies:" - eldev -v dependencies - echo "Testing:" - eldev -dtT test + - uses: purcell/setup-emacs@master + with: + version: ${{ matrix.emacs_version }} + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ matrix.dotnet }} + - uses: actions/checkout@v2 + - name: Install Eldev + run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh + - name: Show dotnet sdks + run: dotnet --list-sdks + - name: Show dotnet version + run: dotnet --info + - name: Test + run: | + echo "Archives:" + eldev archives + echo "Dependencies:" + eldev -v dependencies + echo "Testing:" + eldev -dtT test windows-build: runs-on: windows-latest strategy: fail-fast: false steps: - - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.200 - - name: Show dotnet sdks - run: dotnet --list-sdks - - name: Show dotnet version - run: dotnet --info - - name: Set up Emacs on Windows - uses: jcs090218/setup-emacs-windows@master - with: - version: 28.1 - - uses: actions/checkout@v2 - - name: Install Eldev - run: curl.exe -fsSL https://raw.github.com/doublep/eldev/master/webinstall/eldev.bat | cmd /Q - - name: Test - run: | - echo "Archives:" - ~/.local/bin/eldev.bat archives - echo "Dependencies:" - ~/.local/bin/eldev.bat dependencies - echo "Testing:" - ~/.local/bin/eldev.bat -p -dtT test + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.200 + - name: Show dotnet sdks + run: dotnet --list-sdks + - name: Show dotnet version + run: dotnet --info + - name: Set up Emacs on Windows + uses: jcs090218/setup-emacs-windows@master + with: + version: 28.1 + - uses: actions/checkout@v2 + - name: Install Eldev + run: curl.exe -fsSL https://raw.github.com/doublep/eldev/master/webinstall/eldev.bat | cmd /Q + - name: Test + run: | + echo "Archives:" + ~/.local/bin/eldev.bat archives + echo "Dependencies:" + ~/.local/bin/eldev.bat dependencies + echo "Testing:" + ~/.local/bin/eldev.bat -p -dtT test