Skip to content

Commit 7cc45bd

Browse files
committed
feat(nextflow): Add automatic download
1 parent 8579c6c commit 7cc45bd

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

clients/lsp-nextflow.el

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
;;; Commentary:
2222

2323
;; LSP Clients for the Nextflow Programming Language.
24+
;;
25+
;; The language server JAR will be automatically downloaded from GitHub releases.
2426

2527
;;; Code:
2628

@@ -37,7 +39,7 @@
3739
:group 'lsp-nextflow
3840
:type 'string)
3941

40-
(defcustom lsp-nextflow-version "1.0.0"
42+
(defcustom lsp-nextflow-version "25.04.2"
4143
"Version of Nextflow language server."
4244
:type 'string
4345
:group 'lsp-nextflow
@@ -59,14 +61,33 @@
5961
:type 'file
6062
:package-version '(lsp-mode . "9.0.0"))
6163

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+
6288
(defun lsp-nextflow-server-command ()
6389
"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)))
7091

7192
;;
7293
;;; Settings
@@ -118,10 +139,14 @@ find Java automatically."
118139

119140
(lsp-register-client
120141
(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))))
125150
:major-modes '(nextflow-mode)
126151
:multi-root t
127152
:activation-fn (lsp-activate-on "nextflow")

0 commit comments

Comments
 (0)