Skip to content

Commit 4f987cb

Browse files
authored
Add Nextflow Support (#4606)
* feat: Copy lsp-groovy to lsp-nextflow * chore(nextflow): groovy => nextflow * chore(nextflow): Run lsp-generate-settings * fix(nextflow): Rework install logic * fix(nextflow): Update Nextflow language server installation logic * Add lsp-nextflow-test * chore: Try to start over with actionscript as a template * refactor: Use Nextflow lsp instead of vsix * fix: Add Nextflow-mode to lsp-clients and lsp-mode * fix: It's working? * fix: Reorder client creation and settings * feat: Add initialization function * chore: Bump lsp-mode version * fix: Enable multi-root Idk what this does, but it makes it work * chore: Add TODO * chore: Update formatting * chore: Update Changelog * style: Fix docstring wider than 80 characters * style(nextflow): Fix Summary line
1 parent 9b10410 commit 4f987cb

File tree

5 files changed

+151
-1
lines changed

5 files changed

+151
-1
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* Fix zls wrong bin path
2323
* Add support for buf CLI ([[https://github.com/bufbuild/buf/releases/tag/v1.43.0][beta]])
2424
* Add fennel support
25+
* Add support for [[https://github.com/nextflow-io/language-server][Nextflow]]
2526

2627
** 9.0.0
2728
* Add language server config for QML (Qt Modeling Language) using qmlls.

clients/lsp-nextflow.el

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
;;; lsp-nextflow.el --- lsp-mode nextflow integration -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2024 Edmund Miller
4+
5+
;; Author: Edmund Miller
6+
;; Keywords: lsp, nextflow, groovy
7+
8+
;; This program is free software; you can redistribute it and/or modify
9+
;; it under the terms of the GNU General Public License as published by
10+
;; the Free Software Foundation, either version 3 of the License, or
11+
;; (at your option) any later version.
12+
13+
;; This program is distributed in the hope that it will be useful,
14+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
;; GNU General Public License for more details.
17+
18+
;; You should have received a copy of the GNU General Public License
19+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
21+
;;; Commentary:
22+
23+
;; LSP Clients for the Nextflow Programming Language.
24+
25+
;;; Code:
26+
27+
(require 'lsp-mode)
28+
(require 'f)
29+
30+
(defgroup lsp-nextflow nil
31+
"LSP support for nextflow, using nextflow-language-server."
32+
:group 'lsp-mode
33+
:link '(url-link "https://github.com/nextflow-io/language-server"))
34+
35+
(defcustom lsp-nextflow-java-path "java"
36+
"Path of the java executable."
37+
:group 'lsp-nextflow
38+
:type 'string)
39+
40+
(defcustom lsp-nextflow-version "1.0.0"
41+
"Version of Nextflow language server."
42+
:type 'string
43+
:group 'lsp-nextflow
44+
:package-version '(lsp-mode . "9.0.0"))
45+
46+
(defcustom lsp-nextflow-server-download-url
47+
(format "https://github.com/nextflow-io/language-server/releases/download/v%s/language-server-all.jar"
48+
lsp-nextflow-version)
49+
"Automatic download url for lsp-nextflow."
50+
:type 'string
51+
:group 'lsp-nextflow
52+
:package-version '(lsp-mode . "9.0.0"))
53+
54+
(defcustom lsp-nextflow-server-file
55+
(f-join lsp-server-install-dir "nextflow-language-server.jar")
56+
"The path to the file in which `lsp-nextflow' will be stored."
57+
:group 'lsp-nextflow
58+
:risky t
59+
:type 'file
60+
:package-version '(lsp-mode . "9.0.0"))
61+
62+
(defun lsp-nextflow-server-command ()
63+
"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))
70+
71+
;;
72+
;;; Settings
73+
74+
;; (lsp-generate-settings "~/src/nf-core/vscode-language-nextflow/package.json" 'lsp-nextflow)
75+
76+
(lsp-defcustom lsp-nextflow-debug nil
77+
"Enable debug logging and debug information in hover hints."
78+
:type 'boolean
79+
:group 'lsp-nextflow
80+
:package-version '(lsp-mode . "9.0.0")
81+
:lsp-path "nextflow.debug")
82+
83+
(lsp-defcustom lsp-nextflow-files-exclude [".git" ".nf-test" "work"]
84+
"Configure glob patterns for excluding folders from being searched for
85+
Nextflow scripts and configuration files."
86+
:type 'lsp-string-vector
87+
:group 'lsp-nextflow
88+
:package-version '(lsp-mode . "9.0.0")
89+
:lsp-path "nextflow.files.exclude")
90+
91+
(lsp-defcustom lsp-nextflow-formatting-harshil-alignment nil
92+
"Use the [Harshil Alignment™️](https://nf-co.re/docs/contributing/code_editors_and_styling/harshil_alignment) when formatting Nextflow scripts and config files.
93+
94+
*Note: not all rules are supported yet*"
95+
:type 'boolean
96+
:group 'lsp-nextflow
97+
:package-version '(lsp-mode . "9.0.0")
98+
:lsp-path "nextflow.formatting.harshilAlignment")
99+
100+
(lsp-defcustom lsp-nextflow-java-home nil
101+
"Specifies the folder path to the JDK. Use this setting if the extension cannot
102+
find Java automatically."
103+
:type '(choice (const :tag "Auto" nil)
104+
(directory :tag "Custom JDK path"))
105+
:group 'lsp-nextflow
106+
:package-version '(lsp-mode . "9.0.0")
107+
:lsp-path "nextflow.java.home")
108+
109+
(lsp-defcustom lsp-nextflow-suppress-future-warnings t
110+
"Hide warnings for future changes, deprecations, and removals."
111+
:type 'boolean
112+
:group 'lsp-nextflow
113+
:package-version '(lsp-mode . "9.0.0")
114+
:lsp-path "nextflow.suppressFutureWarnings")
115+
116+
;;
117+
;;; Client
118+
119+
(lsp-register-client
120+
(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)
125+
:major-modes '(nextflow-mode)
126+
:multi-root t
127+
:activation-fn (lsp-activate-on "nextflow")
128+
:priority -1
129+
:initialized-fn (lambda (workspace)
130+
(with-lsp-workspace workspace
131+
(lsp--set-configuration
132+
(lsp-configuration-section "nextflow"))))
133+
;; TODO Handle preview dag
134+
:server-id 'nextflow-lsp))
135+
136+
(lsp-consistency-check lsp-nextflow)
137+
138+
(provide 'lsp-nextflow)
139+
;;; lsp-nextflow.el ends here

docs/lsp-clients.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,14 @@
677677
"installation": "npm install -g @mdx-js/language-server",
678678
"debugger": "Not available"
679679
},
680+
{
681+
"name": "nextflow",
682+
"full-name": "Nextflow",
683+
"server-name": "nextflow-language-server",
684+
"server-url": "https://github.com/nextflow-io/language-server",
685+
"installation-url": "https://github.com/nextflow-io/language-server#build",
686+
"debugger": "Not available"
687+
},
680688
{
681689
"name": "nginx",
682690
"full-name": "Nginx",

lsp-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ As defined by the Language Server Protocol 3.16."
182182
lsp-graphql lsp-groovy lsp-hack lsp-haskell lsp-haxe lsp-idris lsp-java
183183
lsp-javascript lsp-jq lsp-json lsp-kotlin lsp-latex lsp-lisp lsp-ltex
184184
lsp-lua lsp-fennel lsp-magik lsp-markdown lsp-marksman lsp-mdx lsp-meson lsp-metals lsp-mint
185-
lsp-mojo lsp-move lsp-mssql lsp-nginx lsp-nim lsp-nix lsp-nushell lsp-ocaml
185+
lsp-mojo lsp-move lsp-mssql lsp-nextflow lsp-nginx lsp-nim lsp-nix lsp-nushell lsp-ocaml
186186
lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator lsp-php lsp-pls
187187
lsp-purescript lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms
188188
lsp-qml lsp-r lsp-racket lsp-remark lsp-rf lsp-roslyn lsp-rubocop lsp-ruby-lsp
@@ -835,6 +835,7 @@ Changes take effect only when a new session is started."
835835
(java-ts-mode . "java")
836836
(jdee-mode . "java")
837837
(groovy-mode . "groovy")
838+
(nextflow-mode . "nextflow")
838839
(python-mode . "python")
839840
(python-ts-mode . "python")
840841
(cython-mode . "python")

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ nav:
118118
- Move: page/lsp-move.md
119119
- MDX: page/lsp-mdx.md
120120
- MSSQL: https://emacs-lsp.github.io/lsp-mssql
121+
- Nextflow: page/lsp-nextflow.md
121122
- Nginx: page/lsp-nginx.md
122123
- Nim: page/lsp-nim.md
123124
- Nix (nixd-lsp): page/lsp-nix-nixd.md

0 commit comments

Comments
 (0)