Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting of non-Nextflow dollar variables inside script blocks (feature request?) #6

Open
Gullumluvl opened this issue Dec 19, 2024 · 0 comments

Comments

@Gullumluvl
Copy link

Gullumluvl commented Dec 19, 2024

Hi!

I am not sure how to proceed alone to make this change. Note that I am using the fork from @raivivek (https://github.com/raivivek/nextflow.vim) but cannot submit an issue there.

I think it's easier to consider an example script block, in which we mix Bash variables, Awk column names and Nextflow variables. To be correct, you need to escape the dollar signs of all non-Nextflow variables (otherwise Nextflow fails).

script:
"""
linecount=\$(wc -l < $inputfile)
awk -v c=linecount \$count '{print \$1 / c, \$2}' $inputfile > out.txt
"""

(I am making this up).

The thing is, if you forget to escape, that's invalid Nextflow code. Can we have a special highlight (like red background) to spot these? This might become even more relevant since Nextflow decided to deprecate the shell block.

We can unambiguously determine that $1, $2, etc cannot be Nextflow variables (I think). Also for the syntax $(command) which is Bash only.

I read the syntax file, and maybe at this line:

syn region  nextflowBlockString          start=+'''+ keepend end=+'''+ contains=groovySpecialChar,groovySpecialError,@Spell,nextflowELExpr,@shell

we could add an extra contained group such as InvalidGroovyVar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant