|
21 | 21 | ;;; Commentary: |
22 | 22 |
|
23 | 23 | ;; LSP Clients for the Nextflow Programming Language. |
| 24 | +;; |
| 25 | +;; The language server JAR will be automatically downloaded from GitHub releases. |
24 | 26 |
|
25 | 27 | ;;; Code: |
26 | 28 |
|
|
37 | 39 | :group 'lsp-nextflow |
38 | 40 | :type 'string) |
39 | 41 |
|
40 | | -(defcustom lsp-nextflow-version "1.0.0" |
| 42 | +(defcustom lsp-nextflow-version "25.04.2" |
41 | 43 | "Version of Nextflow language server." |
42 | 44 | :type 'string |
43 | 45 | :group 'lsp-nextflow |
|
59 | 61 | :type 'file |
60 | 62 | :package-version '(lsp-mode . "9.0.0")) |
61 | 63 |
|
| 64 | +(defun lsp-nextflow--async-download (callback error-callback) |
| 65 | + "Asynchronously download Nextflow language server JAR file." |
| 66 | + (let ((download-buffer (url-retrieve |
| 67 | + lsp-nextflow-server-download-url |
| 68 | + (lambda (status callback error-callback) |
| 69 | + (if (plist-get status :error) |
| 70 | + (progn |
| 71 | + (message "Nextflow LSP download failed: %s" (plist-get status :error)) |
| 72 | + (funcall error-callback (plist-get status :error))) |
| 73 | + (unwind-protect |
| 74 | + (progn |
| 75 | + (goto-char (point-min)) |
| 76 | + (re-search-forward "\n\n" nil 'noerror) |
| 77 | + (let ((jar-content (buffer-substring (point) (point-max)))) |
| 78 | + (mkdir (f-parent lsp-nextflow-server-file) t) |
| 79 | + (with-temp-file lsp-nextflow-server-file |
| 80 | + (set-buffer-file-coding-system 'binary) |
| 81 | + (insert jar-content)) |
| 82 | + (message "Nextflow LSP download completed: %s" lsp-nextflow-server-file) |
| 83 | + (funcall callback))) |
| 84 | + (kill-buffer (current-buffer))))) |
| 85 | + (list callback error-callback)))) |
| 86 | + (message "Downloading Nextflow LSP server from %s..." lsp-nextflow-server-download-url))) |
| 87 | + |
62 | 88 | (defun lsp-nextflow-server-command () |
63 | 89 | "Startup command for Nextflow language server." |
64 | | - `("java" "-jar" ,(expand-file-name lsp-nextflow-server-file))) |
65 | | - |
66 | | -(lsp-dependency 'nextflow-lsp |
67 | | - '(:system lsp-nextflow-server-file) |
68 | | - `(:download :url lsp-nextflow-server-download-url |
69 | | - :store-path lsp-nextflow-server-file)) |
| 90 | + `(,lsp-nextflow-java-path "-jar" ,(expand-file-name lsp-nextflow-server-file))) |
70 | 91 |
|
71 | 92 | ;; |
72 | 93 | ;;; Settings |
@@ -118,10 +139,14 @@ find Java automatically." |
118 | 139 |
|
119 | 140 | (lsp-register-client |
120 | 141 | (make-lsp-client |
121 | | - ;; FIXME |
122 | | - ;; :download-server-fn (lambda (_client callback error-callback _update?) |
123 | | - ;; (lsp-package-ensure 'nextflow-lsp callback error-callback)) |
124 | | - :new-connection (lsp-stdio-connection #'lsp-nextflow-server-command) |
| 142 | + :download-server-fn (lambda (_client callback error-callback _update?) |
| 143 | + (lsp-nextflow--async-download callback error-callback)) |
| 144 | + :new-connection (lsp-stdio-connection |
| 145 | + (lambda () |
| 146 | + (list |
| 147 | + lsp-nextflow-java-path |
| 148 | + "-jar" |
| 149 | + (expand-file-name lsp-nextflow-server-file)))) |
125 | 150 | :major-modes '(nextflow-mode) |
126 | 151 | :multi-root t |
127 | 152 | :activation-fn (lsp-activate-on "nextflow") |
|
0 commit comments