atom / language-yaml

YAML package for Atom
Other
24 stars 39 forks source link

Add detection of Snakefile #112

Open HDembinski opened 4 years ago

HDembinski commented 4 years ago

Copied from https://github.com/atom/atom/issues/20382

Description

https://snakemake.readthedocs.io/en/stable/ is a popular tool in data science. It parses so-called "Snakefile"s which are similar to "Makefile"s.

The grammar selector detects a "Snakefile" as source.python, but it should be source.yaml. This causes issues with linters and autoformatters like python-black, which should not be run for Snakefiles.

Steps to Reproduce

  1. Generate a file called "Snakefile" with the following content:
    
    import glob

rule all: input: ["data/foo.root", "data/bar.root"]

rule make_foo: input: "{name}.root" output: "{name}_pv.root" shell: "./make_foo.py {input} {output}"



2. Open file in Atom, it is detected as python.source.

**Expected behavior:**

The grammar selector should detect a "Snakefile" as source.yaml.

**Actual behavior:**

The grammar selector detects a "Snakefile" as source.python.

**Reproduces how often:**

Always.

### Versions

Atom    : 1.43.0
Electron: 4.2.7
Chrome  : 69.0.3497.128
Node    : 10.11.0
Nixinova commented 3 years ago

Are Snakefiles not meant to be Python? Search shows that all of them contain python code, and your example includes an import statement.

HDembinski commented 3 years ago

They are neither yaml nor Python. Look closely at the code example, this is not valid Python syntax.