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

Update Snakemake language config #11936

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

TeemuSailynoja
Copy link

@TeemuSailynoja TeemuSailynoja commented Oct 25, 2024

  1. Updated the file-types argument in Snakemake language definition to properly detect the language for Snakefile.
  2. Added a formatter command for Snakemake using snakefmt.

Updated the Snkaemake `file-types` argument to properly detect the language for Snakefile.
@TeemuSailynoja TeemuSailynoja changed the title Update Snakemake file-types Fix Snakemake file-types Oct 25, 2024
call `snakefmt -` to pass stdin to the snakefmt and receive the output through stdout.
@TeemuSailynoja TeemuSailynoja changed the title Fix Snakemake file-types Update Snakemake language config Oct 25, 2024
comment-tokens = ["#", "##"]
indent = { tab-width = 2, unit = " " }
language-servers = ["pylsp" ]

[language.formatter]
command = "snakefmt"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snakefmt is the formatter provided by the Snakemake Github organisation: https://github.com/snakemake/snakefmt

comment-tokens = ["#", "##"]
indent = { tab-width = 2, unit = " " }
language-servers = ["pylsp" ]

[language.formatter]
command = "snakefmt"
args = ["-"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not so clearly documented, but in the warning callout at the start of the Github Readme, they state:

You can also pipe the file in from stdin, which will print it to the screen.

Later, in the last example of Basic Usage they show how to write the output to stdout with

snakefmt - < Snakefile

It turns out, that by removing the < Snakefile part above, snakefmt takes input from stdin and sends the output to stdout.

@@ -3840,11 +3840,14 @@ source = { git = "https://github.com/Decurity/tree-sitter-circom", rev = "021505
name = "snakemake"
scope = "source.snakemake"
roots = ["Snakefile", "config.yaml", "environment.yaml", "workflow/"]
file-types = ["smk", "Snakefile"]
file-types = ["smk", { glob = "Snakefile" } ]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original commit, "Sankefile" was handled as a suffix, when instead Helix should look at the full filename to apply the language. Like Make and Makefile, the Snakemake pipeline is defined in Snakefile. I added the required glob part.

the-mikedavis
the-mikedavis previously approved these changes Oct 30, 2024
@the-mikedavis the-mikedavis added the A-language-support Area: Support for programming/text languages label Oct 30, 2024
@TeemuSailynoja
Copy link
Author

@pascalkuthe, sorry to bother you, but I saw that you reviewed the original Snakemake PR. Could you check this one too, or assign someone for the review?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants