Finally following up with my Helix configuration, which more or less exactly copies the configuration in this thread on GitHub.
Since the nextflow language server isn’t available on Homebrew or other package managers yet, your first step will need to be cloning the source and building it yourself with Gradle. As the README says, this will involve cloning the nextflow source too.
# download the source code
git clone https://github.com/nextflow-io/language-server.git
# change into the source root directory
cd language-server
# clone Nextflow repository
git clone https://github.com/nextflow-io/nextflow ../nextflow
# build language server
make
make
assumes you have gradle installed. Once it has built, the language server can be run with java -jar build/libs/language-server-all.jar
.
To make this accessible to Helix, I just put that a shell script called nextflow-language-server
that looks like this:
#!/bin/bash
java -jar $HOME/language-server/build/libs/language-server-all.jar
After running chmod +x nextflow-language-server
and placing it somewhere that’s on $PATH
, it should be available to Helix (or whatever else).
In my Helix languages.toml
, I can set it up like so:
[[language]]
file-types = ["nf", "nf.test", {glob = "nextflow.config"}]
auto-format = false
language-servers = ["nextflow-language-server"]
name = "nextflow"
grammar = "groovy"
scope = "source.nextflow"
comment-tokens = ["//"]
block-comment-tokens = { start = "/*", end = "*/"}
indent = { tab-width = 4, unit = " " }
[language-server.nextflow-language-server]
command = "nextflow-language-server"
[language-server.nextflow-language-server.config.nextflow]
debug = true
[language-server.nextflow-language-server.config.nextflow.files]
exclude = [".pixi", ".git", ".nf-test", "work"]
[language-server.nextflow-language-server.config.nextflow.formatting]
harshilAlignment = true
(for anyone interested, my full Helix language config is here)
One of the more important lines is grammar = "groovy"
, which tells Helix to use the Groovy tree-sitter grammar for syntax highlighting. This only work if you’ve pulled and built available tree-sitter grammars with:
hx --grammar fetch
hx --grammar build
That should do it! In the near future, the Nextflow LS and a tree-sitter grammar will be available on package managers like Homebrew or Nixpkgs so folks don’t have to build source themselves, but for now, this system works!