├── .github └── workflows │ ├── conventional-prs.yml │ ├── main.yml │ └── release-please.yml ├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── .vscodeignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── languages └── snakemake.json ├── logo-snake.png ├── misc └── example.png ├── package-lock.json ├── package.json ├── reference ├── example.smk ├── reference.smk └── string_sub.smk ├── snippets └── snakemake.json ├── src ├── js │ ├── build_regex.js │ └── keywords-regex.json ├── keywords.yaml └── yaml │ ├── snakemake.language.yaml │ ├── snakemake.snippets.yaml │ └── snakemake.syntax.yaml └── syntaxes └── snakemake.tmLanguage.json /.github/workflows/conventional-prs.yml: -------------------------------------------------------------------------------- 1 | name: Lint PR 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | - reopened 8 | - edited 9 | - synchronize 10 | 11 | jobs: 12 | title-format: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: amannn/action-semantic-pull-request@v3.6.0 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 18 | with: 19 | validateSingleCommit: true 20 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches_ignore: [] 9 | 10 | jobs: 11 | test: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | 18 | - uses: actions/setup-node@v1 19 | with: 20 | node-version: 12 21 | 22 | - run: npm ci -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | release-please: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: GoogleCloudPlatform/release-please-action@v3 13 | id: release 14 | with: 15 | release-type: node 16 | token: ${{ secrets.GITHUB_TOKEN }} 17 | 18 | - uses: actions/checkout@v2 19 | if: ${{ steps.release.outputs.release_created }} 20 | 21 | - uses: actions/setup-node@v1 22 | if: ${{ steps.release.outputs.release_created }} 23 | with: 24 | node-version: 12 25 | 26 | - name: ci 27 | if: ${{ steps.release.outputs.release_created }} 28 | run: npm ci 29 | 30 | - name: Publish to Visual Studio Marketplace 31 | if: ${{ steps.release.outputs.release_created }} 32 | uses: HaaLeo/publish-vscode-extension@v0 33 | with: 34 | pat: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} 35 | registryUrl: https://marketplace.visualstudio.com 36 | 37 | - name: Publish to Open VSX Registry 38 | if: ${{ steps.release.outputs.release_created }} 39 | uses: HaaLeo/publish-vscode-extension@v0 40 | with: 41 | pat: ${{ secrets.OPEN_VSX_TOKEN }} 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.vsix -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "runtimeExecutable": "${execPath}", 13 | "args": [ 14 | "--extensionDevelopmentPath=${workspaceFolder}" 15 | ], 16 | "preLaunchTask": "build" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "regex_build", 6 | "command": "node src/js/build_regex.js src/keywords.yaml src/js/keywords-regex.json", 7 | "type": "shell" 8 | }, 9 | { 10 | "label": "syntax_build", 11 | "dependsOn": "regex_build", 12 | "command": "npx mustache src/js/keywords-regex.json src/yaml/snakemake.syntax.yaml | npx js-yaml > syntaxes/snakemake.tmLanguage.json", 13 | "type": "shell" 14 | }, 15 | { 16 | "label": "language_build", 17 | "command": "npx js-yaml src/yaml/snakemake.language.yaml > languages/snakemake.json", 18 | "type": "shell" 19 | }, 20 | { 21 | "label": "snippets_build", 22 | "command": "npx js-yaml src/yaml/snakemake.snippets.yaml > snippets/snakemake.json", 23 | "type": "shell" 24 | }, 25 | { 26 | "label": "build", 27 | "dependsOn": ["syntax_build", "language_build", "snippets_build"] 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | reference/** 5 | node_modules/** 6 | src/** 7 | package-lock.json 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [0.6.0](https://github.com/snakemake/snakemake-lang-vscode-plugin/compare/v0.5.2...v0.6.0) (2025-04-03) 4 | 5 | 6 | ### Features 7 | 8 | * update more keywords and highlighting ([#42](https://github.com/snakemake/snakemake-lang-vscode-plugin/issues/42)) ([8d455d5](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/8d455d5a5c18c3270d329c62ecf753e681c91ea3)) 9 | 10 | ## [0.5.2](https://github.com/snakemake/snakemake-lang-vscode-plugin/compare/v0.5.1...v0.5.2) (2025-04-01) 11 | 12 | 13 | ### Miscellaneous Chores 14 | 15 | * release 0.5.2 after updating vscode marketplace token ([ffa9524](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/ffa9524d9a98dd44c92e928a3a0b60a051e34d63)) 16 | 17 | ## [0.5.1](https://github.com/snakemake/snakemake-lang-vscode-plugin/compare/v0.5.0...v0.5.1) (2025-03-11) 18 | 19 | 20 | ### Bug Fixes 21 | 22 | * added missing keywords for highlighting ([#30](https://github.com/snakemake/snakemake-lang-vscode-plugin/issues/30)) ([e623a48](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/e623a483fc5af15aea9c9d6cf199262dfa84ff7a)) 23 | 24 | ## [0.5.0](https://github.com/snakemake/snakemake-lang-vscode-plugin/compare/v0.4.0...v0.5.0) (2024-10-20) 25 | 26 | 27 | ### Features 28 | 29 | * Add `retries` keyword ([#31](https://github.com/snakemake/snakemake-lang-vscode-plugin/issues/31)) ([ea88750](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/ea887508abb81f5ed151da95e19358f8a2957e45)) 30 | 31 | ## [0.4.0](https://github.com/snakemake/snakemake-lang-vscode-plugin/compare/v0.3.0...v0.4.0) (2023-08-07) 32 | 33 | 34 | ### Features 35 | 36 | * Add new `localrule` ruleparam to keywords.yaml ([#24](https://github.com/snakemake/snakemake-lang-vscode-plugin/issues/24)) ([b046590](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/b046590fb61d50a176649a336e6037451e3ba055)) 37 | * auto closing rule for triple double quotes ([0043178](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/004317818211ce74501de26bb9eb4a1d400795de)) 38 | 39 | 40 | ### Bug Fixes 41 | 42 | * restrictions to function keywords (word boundary) ([#16](https://github.com/snakemake/snakemake-lang-vscode-plugin/issues/16)) ([0043178](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/004317818211ce74501de26bb9eb4a1d400795de)) 43 | 44 | ## [0.3.0](https://github.com/snakemake/snakemake-lang-vscode-plugin/compare/v0.2.0...v0.3.0) (2023-08-07) 45 | 46 | 47 | ### Features 48 | 49 | * add template_engine keyword ([16cd7d4](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/16cd7d4e02c4ac8685fec46c4d61f84ec90827d3)) 50 | 51 | ## [0.2.0](https://github.com/snakemake/snakemake-lang-vscode-plugin/compare/v0.1.8...v0.2.0) (2022-10-09) 52 | 53 | 54 | ### Features 55 | 56 | * update keywords and implement autoindentation ([#17](https://github.com/snakemake/snakemake-lang-vscode-plugin/issues/17)) ([7762354](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/776235401264754bd14a16a944f70f0e45da1cda)) 57 | 58 | ## [1.1.0](https://github.com/ftabaro/snakemake-lang-vscode-plugin/compare/v1.0.0...v1.1.0) (2022-08-26) 59 | 60 | 61 | ### Features 62 | 63 | * Implement onEnterRules ([e77976f](https://github.com/ftabaro/snakemake-lang-vscode-plugin/commit/e77976ff72656fb1e72f026d93bc6368311d5662)) 64 | 65 | ## 1.0.0 (2022-08-25) 66 | 67 | 68 | ### Bug Fixes 69 | 70 | * add more rule keywords ([e99bc9c](https://github.com/ftabaro/snakemake-lang-vscode-plugin/commit/e99bc9cff84d3c4f9045487a57e62aad26767a96)) 71 | * adjusted release type ([8f15738](https://github.com/ftabaro/snakemake-lang-vscode-plugin/commit/8f15738c3e54c3655a0a5a2c0099380b097ee76f)) 72 | 73 | ### [0.1.8](https://github.com/snakemake/snakemake-lang-vscode-plugin/compare/v0.1.7...v0.1.8) (2022-03-30) 74 | 75 | 76 | ### Bug Fixes 77 | 78 | * adjusted release type ([8f15738](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/8f15738c3e54c3655a0a5a2c0099380b097ee76f)) 79 | 80 | ### [0.1.7](https://github.com/snakemake/snakemake-lang-vscode-plugin/compare/v0.1.6...v0.1.7) (2022-03-30) 81 | 82 | 83 | ### Bug Fixes 84 | 85 | * add more rule keywords ([e99bc9c](https://github.com/snakemake/snakemake-lang-vscode-plugin/commit/e99bc9cff84d3c4f9045487a57e62aad26767a96)) 86 | 87 | ## 0.1.1 (2019-11-26) 88 | 89 | - Updated Changelog 90 | 91 | ## 0.1.0 (2019-11-26) 92 | 93 | - Updated build process to use templating for the keyword regular expressions 94 | - Added script snippet 95 | - Bumped version number to 0.1.0 as the extension seems reasonably stable now 96 | 97 | ## 0.0.6 (2019-10-21) 98 | 99 | - Updated --baseContentUrl to get example image to work 100 | 101 | ## 0.0.5 (2019-10-18) 102 | 103 | - New keyword: singularity 104 | - Added example image to README 105 | 106 | ## 0.0.4 (2019-10-18) 107 | 108 | - Fixed faulty Rule snippet 109 | - Converted definitions to YAML source 110 | - Removed indentation rules until they work properly 111 | 112 | ## 0.0.3 (2019-10-17) 113 | 114 | - New keywords: subworkflow, checkpoint, configfile, snakefile, ruleorder, localrules, onsuccess, onerror, onstart, priority, shadow, group, cwl 115 | - New functions: ancient, directory, touch, pipe 116 | 117 | ## 0.0.2 (2019-10-17) 118 | 119 | - New keywords: conda, wildcard_constraints, wrapper 120 | - New functions: expand, unpack, temp, protected 121 | - Support for unnamed rules 122 | 123 | ## 0.0.1 (2019-10-15) 124 | 125 | - Initial release 126 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Peter Alping 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Snakemake Language Support 2 | 3 | Provides basic language support for [Snakemake](https://snakemake.readthedocs.io) files (Snakefile, *.smk). 4 | Feedback, suggestions, and contributions are very welcome! 5 | 6 | This project has been started by Peter Alping, and can be considered a fork of [this repository](https://gitlab.com/alping/vscode-snakemake). 7 | 8 | ## Features 9 | 10 | - Syntax definitions based on Python, with added Snakemake keywords 11 | - Language rules based on Python 12 | - Snippets 13 | 14 | ## Example 15 | 16 | ![Snakemake syntax highlighting example](misc/example.png) 17 | 18 | 22 | 23 | Example taken from [Snakemake documentation](https://snakemake.readthedocs.io/en/stable/tutorial/advanced.html#summary). 24 | 25 | ## Supported Syntax 26 | 27 |
28 | 29 | Keywords and Functions 30 | 31 | - Configurations 32 | - configfile 33 | - include 34 | - localrules 35 | - onerror 36 | - onstart 37 | - onsuccess 38 | - ruleorder 39 | - snakefile 40 | - workdir 41 | - Rules 42 | - checkpoint 43 | - rule 44 | - subworkflow 45 | - Rule Parameters 46 | - benchmark 47 | - conda 48 | - cwl 49 | - group 50 | - input 51 | - log 52 | - message 53 | - output 54 | - params 55 | - priority 56 | - resources 57 | - run 58 | - script 59 | - shadow 60 | - shell 61 | - singularity 62 | - threads 63 | - version 64 | - wildcard_constraints 65 | - wrapper 66 | - Functions 67 | - ancient 68 | - directory 69 | - expand 70 | - pipe 71 | - protected 72 | - temp 73 | - touch 74 | - unpack 75 | 76 |
77 | 78 | ## TODO 79 | 80 | - [ ] Indentation rules (really tricky for some reason) 81 | - [ ] Recognize string substitutions: `"command {input}"` 82 | - [ ] Recognize wildcard constraints inside string substitutions: `"{sample,[A-Za-z0-9]+}"` 83 | 84 | ## Snakemake Support for other Editors 85 | 86 | - [Vim](https://github.com/snakemake/snakemake/tree/master/misc/vim) 87 | -------------------------------------------------------------------------------- /languages/snakemake.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "#", 4 | "blockComment": [ 5 | "\"\"\"", 6 | "\"\"\"" 7 | ] 8 | }, 9 | "brackets": [ 10 | [ 11 | "{", 12 | "}" 13 | ], 14 | [ 15 | "[", 16 | "]" 17 | ], 18 | [ 19 | "(", 20 | ")" 21 | ] 22 | ], 23 | "autoClosingPairs": [ 24 | [ 25 | "{", 26 | "}" 27 | ], 28 | [ 29 | "[", 30 | "]" 31 | ], 32 | [ 33 | "(", 34 | ")" 35 | ], 36 | [ 37 | "\"\"\"", 38 | "\"\"\"" 39 | ], 40 | [ 41 | "\"", 42 | "\"" 43 | ], 44 | [ 45 | "r\"", 46 | "\"" 47 | ], 48 | [ 49 | "f\"", 50 | "\"" 51 | ], 52 | [ 53 | "b\"", 54 | "\"" 55 | ], 56 | [ 57 | "'", 58 | "'" 59 | ], 60 | [ 61 | "r'", 62 | "'" 63 | ], 64 | [ 65 | "f'", 66 | "'" 67 | ], 68 | [ 69 | "b'", 70 | "'" 71 | ] 72 | ], 73 | "surroundingPairs": [ 74 | [ 75 | "{", 76 | "}" 77 | ], 78 | [ 79 | "[", 80 | "]" 81 | ], 82 | [ 83 | "(", 84 | ")" 85 | ], 86 | [ 87 | "\"", 88 | "\"" 89 | ], 90 | [ 91 | "'", 92 | "'" 93 | ] 94 | ], 95 | "onEnterRules": [ 96 | { 97 | "beforeText": "\\s*(?:(?:checkpoint|rule|module|subworkflow|async|class|def|elif|except|for|if|while|with)\\s.*|(?:envvars|include|workdir|configfile|pepfile|pepschema|report|ruleorder|localrules|onsuccess|onerror|onstart|wildcard_constraints|singularity|container|containerized|conda|scattergather|inputflags|outputflags|storage|resource_scopes|name|input|output|params|threads|resources|retries|priority|log|message|benchmark|envmodules|shadow|group|cache|handover|default_target|localrule|version|run|shell|script|notebook|wrapper|template_engine|cwl|snakefile|meta_wrapper|config|skip_validation|replace_prefix|prefix|else|finally|try))\\s*:\\s*(?:#.*)?$", 98 | "action": { 99 | "indent": "indent" 100 | } 101 | } 102 | ] 103 | } 104 | -------------------------------------------------------------------------------- /logo-snake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snakemake/snakemake-lang-vscode-plugin/d15435c3378d14c8640d4093eca4a36613226868/logo-snake.png -------------------------------------------------------------------------------- /misc/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snakemake/snakemake-lang-vscode-plugin/d15435c3378d14c8640d4093eca4a36613226868/misc/example.png -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "snakemake-lang", 3 | "version": "0.6.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "snakemake-lang", 9 | "version": "0.6.0", 10 | "license": "MIT", 11 | "devDependencies": { 12 | "js-yaml": "^3.13.1", 13 | "mustache": "^3.1.0" 14 | }, 15 | "engines": { 16 | "vscode": "^1.39.0" 17 | } 18 | }, 19 | "node_modules/argparse": { 20 | "version": "1.0.10", 21 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 22 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 23 | "dev": true, 24 | "dependencies": { 25 | "sprintf-js": "~1.0.2" 26 | } 27 | }, 28 | "node_modules/esprima": { 29 | "version": "4.0.1", 30 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 31 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", 32 | "dev": true, 33 | "bin": { 34 | "esparse": "bin/esparse.js", 35 | "esvalidate": "bin/esvalidate.js" 36 | }, 37 | "engines": { 38 | "node": ">=4" 39 | } 40 | }, 41 | "node_modules/js-yaml": { 42 | "version": "3.13.1", 43 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", 44 | "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", 45 | "dev": true, 46 | "dependencies": { 47 | "argparse": "^1.0.7", 48 | "esprima": "^4.0.0" 49 | }, 50 | "bin": { 51 | "js-yaml": "bin/js-yaml.js" 52 | } 53 | }, 54 | "node_modules/mustache": { 55 | "version": "3.1.0", 56 | "resolved": "https://registry.npmjs.org/mustache/-/mustache-3.1.0.tgz", 57 | "integrity": "sha512-3Bxq1R5LBZp7fbFPZzFe5WN4s0q3+gxZaZuZVY+QctYJiCiVgXHOTIC0/HgZuOPFt/6BQcx5u0H2CUOxT/RoGQ==", 58 | "dev": true, 59 | "bin": { 60 | "mustache": "bin/mustache" 61 | }, 62 | "engines": { 63 | "npm": ">=1.4.0" 64 | } 65 | }, 66 | "node_modules/sprintf-js": { 67 | "version": "1.0.3", 68 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 69 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 70 | "dev": true 71 | } 72 | }, 73 | "dependencies": { 74 | "argparse": { 75 | "version": "1.0.10", 76 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 77 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 78 | "dev": true, 79 | "requires": { 80 | "sprintf-js": "~1.0.2" 81 | } 82 | }, 83 | "esprima": { 84 | "version": "4.0.1", 85 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 86 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", 87 | "dev": true 88 | }, 89 | "js-yaml": { 90 | "version": "3.13.1", 91 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", 92 | "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", 93 | "dev": true, 94 | "requires": { 95 | "argparse": "^1.0.7", 96 | "esprima": "^4.0.0" 97 | } 98 | }, 99 | "mustache": { 100 | "version": "3.1.0", 101 | "resolved": "https://registry.npmjs.org/mustache/-/mustache-3.1.0.tgz", 102 | "integrity": "sha512-3Bxq1R5LBZp7fbFPZzFe5WN4s0q3+gxZaZuZVY+QctYJiCiVgXHOTIC0/HgZuOPFt/6BQcx5u0H2CUOxT/RoGQ==", 103 | "dev": true 104 | }, 105 | "sprintf-js": { 106 | "version": "1.0.3", 107 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 108 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 109 | "dev": true 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "snakemake-lang", 3 | "displayName": "Snakemake Language", 4 | "icon": "logo-snake.png", 5 | "description": "Basic syntax, language, and snippet support for Snakefiles (Snakemake workflow definition files)", 6 | "version": "0.6.0", 7 | "publisher": "snakemake", 8 | "license": "MIT", 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/snakemake/snakemake-lang-vscode-plugin" 12 | }, 13 | "bugs": { 14 | "url": "https://github.com/snakemake/snakemake-lang-vscode-plugin/issues" 15 | }, 16 | "engines": { 17 | "vscode": "^1.53.0" 18 | }, 19 | "categories": [ 20 | "Programming Languages" 21 | ], 22 | "contributes": { 23 | "configurationDefaults": { 24 | "files.watcherExclude": { 25 | "**/.snakemake/**": true 26 | }, 27 | "search.exclude": { 28 | "**/.snakemake/**": true 29 | } 30 | }, 31 | "languages": [ 32 | { 33 | "id": "snakemake", 34 | "aliases": [ 35 | "Snakemake", 36 | "snakemake" 37 | ], 38 | "filenames": [ 39 | "Snakefile" 40 | ], 41 | "extensions": [ 42 | ".smk", 43 | ".Snakefile" 44 | ], 45 | "configuration": "./languages/snakemake.json" 46 | } 47 | ], 48 | "grammars": [ 49 | { 50 | "language": "snakemake", 51 | "scopeName": "source.python.snakemake", 52 | "path": "./syntaxes/snakemake.tmLanguage.json" 53 | } 54 | ], 55 | "snippets": [ 56 | { 57 | "language": "snakemake", 58 | "path": "./snippets/snakemake.json" 59 | } 60 | ] 61 | }, 62 | "devDependencies": { 63 | "js-yaml": "^3.13.1", 64 | "mustache": "^3.1.0" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /reference/example.smk: -------------------------------------------------------------------------------- 1 | # Source: https://snakemake.readthedocs.io/en/stable/tutorial/advanced.html#summary 2 | 3 | configfile: "config.yaml" 4 | 5 | rule all: 6 | input: 7 | "plots/quals.svg" 8 | 9 | rule bwa_map: 10 | input: 11 | "data/genome.fa", 12 | lambda wildcards: config["samples"][wildcards.sample] 13 | output: 14 | temp("mapped_reads/{sample}.bam") 15 | params: 16 | rg=r"@RG\tID:{sample}\tSM:{sample}" 17 | log: 18 | "logs/bwa_mem/{sample}.log" 19 | threads: 8 20 | shell: 21 | "(bwa mem -R '{params.rg}' -t {threads} {input} | " 22 | "samtools view -Sb - > {output}) 2> {log}" 23 | 24 | rule samtools_sort: 25 | input: 26 | "mapped_reads/{sample}.bam" 27 | output: 28 | protected("sorted_reads/{sample}.bam") 29 | shell: 30 | "samtools sort -T sorted_reads/{wildcards.sample} " 31 | "-O bam {input} > {output}" 32 | 33 | rule samtools_index: 34 | input: 35 | "sorted_reads/{sample}.bam" 36 | output: 37 | "sorted_reads/{sample}.bam.bai" 38 | shell: 39 | "samtools index {input}" 40 | 41 | rule bcftools_call: 42 | input: 43 | fa="data/genome.fa", 44 | bam=expand("sorted_reads/{sample}.bam", sample=config["samples"]), 45 | bai=expand("sorted_reads/{sample}.bam.bai", sample=config["samples"]) 46 | output: 47 | "calls/all.vcf" 48 | shell: 49 | "samtools mpileup -g -f {input.fa} {input.bam} | " 50 | "bcftools call -mv - > {output}" 51 | 52 | rule plot_quals: 53 | input: 54 | "calls/all.vcf" 55 | output: 56 | "plots/quals.svg" 57 | script: 58 | "scripts/plot-quals.py" 59 | -------------------------------------------------------------------------------- /reference/reference.smk: -------------------------------------------------------------------------------- 1 | # Modularization 2 | # https://snakemake.readthedocs.io/en/stable/tutorial/additional_features.html#modularization 3 | include: "path/to/other.snakefile" 4 | 5 | # Onstart, onsuccess and onerror handlers 6 | # https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#onstart-onsuccess-and-onerror-handlers 7 | onstart: 8 | print("Workflow started") 9 | 10 | onsuccess: 11 | print("Workflow finished, no errors") 12 | 13 | onerror: 14 | print("An error occurred") 15 | 16 | # Containerization 17 | container: "docker://something/here" 18 | containerized: "docker://something/here" 19 | 20 | # Pep schema 21 | pepfile: "path/to/pepconfig.yaml" 22 | pepschema: "https://pepschema.org" 23 | 24 | # Handling Ambiguous Rules 25 | # https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#handling-ambiguous-rules 26 | ruleorder: rule1 > rule2 > rule3 27 | 28 | # Local Rules 29 | # https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#local-rules 30 | localrules: all, foo 31 | 32 | # Standard Configuration 33 | # https://snakemake.readthedocs.io/en/stable/snakefiles/configuration.html#standard-configuration 34 | configfile: "path/to/config.json 35 | 36 | # Sub-Workflows 37 | # https://snakemake.readthedocs.io/en/stable/snakefiles/modularization.html#sub-workflows 38 | subworkflow otherworkflow: 39 | workdir: 40 | "../path/to/otherworkflow" 41 | snakefile: 42 | "../path/to/otherworkflow/Snakefile" 43 | configfile: 44 | "path/to/custom_configfile.yaml" 45 | 46 | rule a: 47 | input: 48 | otherworkflow("test.txt") 49 | output: ... 50 | shell: ... 51 | 52 | # Data-dependent conditional execution 53 | # https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#data-dependent-conditional-execution 54 | checkpoint somestep: 55 | input: 56 | "samples/{sample}.txt" 57 | output: 58 | "somestep/{sample}.txt" 59 | shell: 60 | "somecommand {input} > {output}" 61 | 62 | # General reference 63 | rule reference_rule: 64 | input: 65 | "input/main_input.csv", 66 | ancient("path/to/inputfile"), 67 | expand("input/sample_input_{sample}.csv"], sample=range(10)) 68 | output: 69 | "output/main_output.csv", 70 | directory("path/to/outputdir"), 71 | protected("output/protected_output.csv"), 72 | temp("output/temp_output.csv"), 73 | pipe("test.{i}.txt"), 74 | expand("output/sample_output_{sample}.csv"], sample=range(10)), 75 | report("fig1.png", category="main category") 76 | conda: 77 | "envs/environment.yml" 78 | params: 79 | threads = "4" 80 | priority: 50 81 | shadow: "shallow" 82 | group: "mygroup" 83 | singularity: 84 | "docker://something/here" 85 | container: 86 | "docker://something/here" 87 | shell: 88 | "fastqc -o data/fastqc -t {params.threads} {input}" 89 | 90 | # Benchmarking 91 | # https://snakemake.readthedocs.io/en/stable/tutorial/additional_features.html#benchmarking 92 | rule bwa_map: 93 | input: 94 | "data/genome.fa", 95 | lambda wildcards: config["samples"][wildcards.sample] 96 | output: 97 | temp("mapped_reads/{sample}.bam") 98 | params: 99 | rg="@RG\tID:{sample}\tSM:{sample}" 100 | log: 101 | "logs/bwa_mem/{sample}.log" 102 | benchmark: 103 | "benchmarks/{sample}.bwa.benchmark.txt" 104 | threads: 8 105 | shell: 106 | "(bwa mem -R '{params.rg}' -t {threads} {input} | " 107 | "samtools view -Sb - > {output}) 2> {log}" 108 | 109 | 110 | # Wildcard constraints 111 | # https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#wildcards 112 | rule complex_conversion: 113 | input: 114 | "{dataset}/inputfile" 115 | output: 116 | "{dataset}/file.{group}.txt" 117 | wildcard_constraints: 118 | dataset="\d+" 119 | shell: 120 | "somecommand --group {wildcards.group} < {input} > {output}" 121 | 122 | 123 | # Tool wrappers 124 | # https://snakemake.readthedocs.io/en/stable/tutorial/additional_features.html#tool-wrappers 125 | rule bwa_mem: 126 | input: 127 | ref="data/genome.fa", 128 | sample=lambda wildcards: config["samples"][wildcards.sample] 129 | output: 130 | temp("mapped_reads/{sample}.bam") 131 | log: 132 | "logs/bwa_mem/{sample}.log" 133 | params: 134 | "-R '@RG\tID:{sample}\tSM:{sample}'" 135 | threads: 8 136 | wrapper: 137 | "0.15.3/bio/bwa/mem" 138 | 139 | # Input Functions and unpack() 140 | # https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#input-functions-and-unpack 141 | def myfunc(wildcards): 142 | return { 'foo': '{wildcards.token}.txt'.format(wildcards=wildcards) } 143 | 144 | rule: 145 | input: unpack(myfunc) 146 | output: "someoutput.{token}.txt" 147 | shell: "..." 148 | 149 | # Flag Files 150 | # https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#flag-files 151 | rule mytask: 152 | output: touch("mytask.done") 153 | shell: "mycommand ..." 154 | 155 | # Common-Workflow-Language (CWL) support 156 | # https://snakemake.readthedocs.io/en/stable/snakefiles/modularization.html#common-workflow-language-cwl-support 157 | rule samtools_sort: 158 | input: 159 | input="mapped/{sample}.bam" 160 | output: 161 | output_name="mapped/{sample}.sorted.bam" 162 | params: 163 | threads=lambda wildcards, threads: threads, 164 | memory="4G" 165 | threads: 8 166 | cwl: 167 | "https://github.com/common-workflow-language/workflows/blob/" 168 | "fb406c95/tools/samtools-sort.cwl" 169 | -------------------------------------------------------------------------------- /reference/string_sub.smk: -------------------------------------------------------------------------------- 1 | "path/{outputname}.ext" 2 | 3 | "command {wildcards.outputname} {output}" 4 | 5 | expand("path/{filename}.ext", filename=range(10)) 6 | 7 | expand("{sample,[A-Za-z0-9]+}") 8 | -------------------------------------------------------------------------------- /snippets/snakemake.json: -------------------------------------------------------------------------------- 1 | { 2 | "Snakemake Rule": { 3 | "prefix": "smk-rule", 4 | "description": "Snakemake rule", 5 | "body": [ 6 | "rule ${1:name}:", 7 | "\tinput: $2", 8 | "\toutput: $3", 9 | "\t${4|run,shell,script|}: $0" 10 | ] 11 | }, 12 | "Snakemake Script Rule": { 13 | "prefix": "smk-script", 14 | "description": "Snakemake script rule", 15 | "body": [ 16 | "rule ${1:name}:", 17 | "\tinput: $2", 18 | "\toutput: $3", 19 | "\tscript: \"$0\"" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/js/build_regex.js: -------------------------------------------------------------------------------- 1 | const yaml = require('js-yaml'); 2 | const fs = require('fs'); 3 | 4 | const args = process.argv; 5 | 6 | keywords = args[2]; 7 | outfile = args[3]; 8 | 9 | try { 10 | const config = yaml.safeLoad(fs.readFileSync(keywords, 'utf8')); 11 | var results = {} 12 | for (var key in config) { 13 | results[key] = config[key].join("|") 14 | } 15 | fs.writeFileSync(outfile, JSON.stringify(results, null, 4)); 16 | } catch (e) { 17 | console.log(e); 18 | } 19 | -------------------------------------------------------------------------------- /src/js/keywords-regex.json: -------------------------------------------------------------------------------- 1 | { 2 | "configs": "envvars|include|workdir|configfile|pepfile|pepschema|report|ruleorder|localrules|onsuccess|onerror|onstart|wildcard_constraints|singularity|container|containerized|conda|scattergather|inputflags|outputflags|storage|resource_scopes", 3 | "rules": "checkpoint|rule", 4 | "modules": "module|subworkflow", 5 | "ruleparams": "name|input|output|params|threads|resources|retries|priority|log|message|benchmark|conda|singularity|container|containerized|envmodules|wildcard_constraints|shadow|group|cache|handover|default_target|localrule|version|container_img|is_containerized|shellcmd|norun|conda_env|env_modules|shadow_depth|docstring|path_modifier", 6 | "rulerunparams": "run|shell|script|notebook|wrapper|template_engine|cwl", 7 | "moduleparams": "name|snakefile|meta_wrapper|config|skip_validation|replace_prefix|prefix", 8 | "classes": "Path|WorkflowError", 9 | "objects": "snakemake|rules|workflow|checkpoints|storage|access|scatter|gather", 10 | "ruleargs": "input|output|params|wildcards|threads|resources|log|config", 11 | "functions": "shell|github|gitlab|gitfile|from_queue|protected|temp|temporary|ancient|directory|expand|glob_wildcards|flag|touch|unpack|local|pipe|service|repeat|report|multiext|ensure|update|before_update|lookup|evaluate|branch|collect|exists|subpath|parse_input|extract_checksum|flatten" 12 | } -------------------------------------------------------------------------------- /src/keywords.yaml: -------------------------------------------------------------------------------- 1 | configs: 2 | - envvars 3 | - include 4 | - workdir 5 | - configfile 6 | - pepfile 7 | - pepschema 8 | - report 9 | - ruleorder 10 | - localrules 11 | - onsuccess 12 | - onerror 13 | - onstart 14 | - wildcard_constraints 15 | - singularity 16 | - container 17 | - containerized 18 | - conda 19 | - scattergather 20 | - inputflags 21 | - outputflags 22 | - storage 23 | - resource_scopes 24 | 25 | rules: 26 | - checkpoint 27 | - rule 28 | 29 | modules: 30 | - module 31 | - subworkflow 32 | 33 | ruleparams: 34 | - name 35 | - input 36 | - output 37 | - params 38 | - threads 39 | - resources 40 | - retries 41 | - priority 42 | - log 43 | - message 44 | - benchmark 45 | - conda 46 | - singularity 47 | - container 48 | - containerized 49 | - envmodules 50 | - wildcard_constraints 51 | - shadow 52 | - group 53 | - cache 54 | - handover 55 | - default_target 56 | - localrule 57 | - version 58 | - container_img 59 | - is_containerized 60 | - shellcmd 61 | - norun 62 | - conda_env 63 | - env_modules 64 | - shadow_depth 65 | - docstring 66 | - path_modifier 67 | 68 | rulerunparams: 69 | - run 70 | - shell 71 | - script 72 | - notebook 73 | - wrapper 74 | - template_engine 75 | - cwl 76 | 77 | moduleparams: 78 | - name 79 | - snakefile 80 | - meta_wrapper 81 | - config 82 | - skip_validation 83 | - replace_prefix 84 | - prefix 85 | 86 | classes: 87 | - Path 88 | - WorkflowError 89 | 90 | objects: 91 | - snakemake 92 | - rules 93 | - workflow 94 | - checkpoints 95 | - storage 96 | - access 97 | - scatter 98 | - gather 99 | 100 | ruleargs: 101 | - input 102 | - output 103 | - params 104 | - wildcards 105 | - threads 106 | - resources 107 | - log 108 | - config 109 | 110 | functions: 111 | - shell 112 | - github 113 | - gitlab 114 | - gitfile 115 | - from_queue 116 | - protected 117 | - temp 118 | - temporary 119 | - ancient 120 | - directory 121 | - expand 122 | - glob_wildcards 123 | - flag 124 | - touch 125 | - unpack 126 | - local 127 | - pipe 128 | - service 129 | - repeat 130 | - report 131 | - multiext 132 | - ensure 133 | - update 134 | - before_update 135 | - lookup 136 | - evaluate 137 | - branch 138 | - collect 139 | - exists 140 | - subpath 141 | - parse_input 142 | - extract_checksum 143 | - flatten 144 | -------------------------------------------------------------------------------- /src/yaml/snakemake.language.yaml: -------------------------------------------------------------------------------- 1 | comments: 2 | lineComment: "#" 3 | blockComment: ['"""', '"""'] 4 | 5 | brackets: 6 | - ["{", "}"] 7 | - ["[", "]"] 8 | - ["(", ")"] 9 | 10 | autoClosingPairs: 11 | - ["{", "}"] 12 | - ["[", "]"] 13 | - ["(", ")"] 14 | - ['"""', '"""'] 15 | - ['"', '"'] 16 | - ['r"', '"'] 17 | - ['f"', '"'] 18 | - ['b"', '"'] 19 | - ["'", "'"] 20 | - ["r'", "'"] 21 | - ["f'", "'"] 22 | - ["b'", "'"] 23 | 24 | surroundingPairs: 25 | - ["{", "}"] 26 | - ["[", "]"] 27 | - ["(", ")"] 28 | - ['"', '"'] 29 | - ["'", "'"] 30 | 31 | # Indentation rules do not currently work, as blank space is seemingly not 32 | # enough to decrease indentation so the indentation just keeps increasing 33 | # 34 | # indentationRules: 35 | # increaseIndentPattern: ^\s*(?:(?:rule|subworkflow|checkpoint|async|class|def|elif|except|for|if|while|with)\b.*|(input|output|params|priority|shadow|group|log|benchmark|message|threads|resources|version|run|shell|script|cwl|conda|singularity|wildcard_constraints|wrapper|else|finally|try))\s*:\s*(#.*)?$ 36 | # decreaseIndentPattern: ^\s*(?:else|finally|(?:elif|except)\b.*)\s*:\s*(#.*)?$ 37 | 38 | onEnterRules: 39 | - beforeText: \s*(?:(?:checkpoint|rule|module|subworkflow|async|class|def|elif|except|for|if|while|with)\s.*|(?:envvars|include|workdir|configfile|pepfile|pepschema|report|ruleorder|localrules|onsuccess|onerror|onstart|wildcard_constraints|singularity|container|containerized|conda|scattergather|inputflags|outputflags|storage|resource_scopes|name|input|output|params|threads|resources|retries|priority|log|message|benchmark|envmodules|shadow|group|cache|handover|default_target|localrule|version|run|shell|script|notebook|wrapper|template_engine|cwl|snakefile|meta_wrapper|config|skip_validation|replace_prefix|prefix|else|finally|try))\s*:\s*(?:#.*)?$ 40 | 41 | action: 42 | indent: indent 43 | -------------------------------------------------------------------------------- /src/yaml/snakemake.snippets.yaml: -------------------------------------------------------------------------------- 1 | Snakemake Rule: 2 | prefix: smk-rule 3 | description: Snakemake rule 4 | body: 5 | - "rule ${1:name}:" 6 | - "\tinput: $2" 7 | - "\toutput: $3" 8 | - "\t${4|run,shell,script|}: $0" 9 | 10 | Snakemake Script Rule: 11 | prefix: smk-script 12 | description: Snakemake script rule 13 | body: 14 | - "rule ${1:name}:" 15 | - "\tinput: $2" 16 | - "\toutput: $3" 17 | - "\tscript: \"$0\"" 18 | -------------------------------------------------------------------------------- /src/yaml/snakemake.syntax.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Snakemake 3 | scopeName: source.python.snakemake 4 | fileTypes: [Snakefile, smk] 5 | 6 | patterns: 7 | - include: "#quotessmall" 8 | - include: "#quotesmid" 9 | - include: "#quotesbig" 10 | - include: "#configs" 11 | - include: "#rules" 12 | - include: "#modules" 13 | - include: "#useruleas" 14 | - include: "#userulefromas" 15 | - include: "#userulesfrom" 16 | - include: "#ruleparams" 17 | - include: "#rulerunparams" 18 | - include: "#moduleparams" 19 | - include: "#classes" 20 | - include: "#object" 21 | - include: "#ruleargargs" 22 | - include: "#ruleargs" 23 | - include: "#functions" 24 | # - include: '#snakestrings' 25 | - include: source.python 26 | 27 | repository: 28 | quotessmall: 29 | begin: \( 30 | end: \) 31 | patterns: 32 | - include: "#quotessmall" 33 | - include: "#quotesmid" 34 | - include: "#quotesbig" 35 | - include: "#classes" 36 | - include: "#object" 37 | - include: "#ruleargargs" 38 | - include: "#ruleargs" 39 | - include: "#functions" 40 | - include: source.python 41 | quotesmid: 42 | begin: \[ 43 | end: \] 44 | patterns: 45 | - include: "#quotessmall" 46 | - include: "#quotesmid" 47 | - include: "#quotesbig" 48 | - include: "#classes" 49 | - include: "#object" 50 | - include: "#ruleargargs" 51 | - include: "#ruleargs" 52 | - include: "#functions" 53 | - include: source.python 54 | quotesbig: 55 | begin: \{ 56 | end: \} 57 | patterns: 58 | - include: "#quotessmall" 59 | - include: "#quotesmid" 60 | - include: "#quotesbig" 61 | - include: "#classes" 62 | - include: "#object" 63 | - include: "#ruleargargs" 64 | - include: "#ruleargs" 65 | - include: "#functions" 66 | - include: source.python 67 | configs: 68 | match: > 69 | (?x) 70 | ^\s* # Leading whitespace 71 | ({{configs}}) # Keywords 72 | : # Ending in colon 73 | captures: 74 | "1": { name: keyword.control.snakemake.config } 75 | 76 | rules: 77 | match: > 78 | (?x) 79 | ^\s* # Leading whitespace 80 | ({{rules}}) # Keywords 81 | (?:\s+(\w+))? # Optional rule name 82 | : # Ending in colon 83 | captures: 84 | "1": { name: keyword.control.snakemake } 85 | "2": { name: entity.name.function.snakemake.rule } 86 | 87 | modules: 88 | match: > 89 | (?x) 90 | ^\s* # Leading whitespace 91 | ({{modules}}) # Keywords 92 | (?:\s+(\w+))? # Optional rule name 93 | : # Ending in colon 94 | captures: 95 | "1": { name: keyword.control.snakemake } 96 | "2": { name: entity.name.type.snakemake.rule } 97 | 98 | useruleas: 99 | match: > 100 | (?x) 101 | \b(use\s+rule)\s+(\w+)\s+(as)\s+(\w+)\s+(with) 102 | : # Ending in colon 103 | captures: 104 | "1": { name: keyword.control.snakemake } 105 | "2": { name: entity.name.function.snakemake.rule } 106 | "3": { name: keyword.control.snakemake } 107 | "4": { name: entity.name.function.snakemake.rule } 108 | "5": { name: keyword.control.snakemake } 109 | 110 | userulesfromas: 111 | match: > 112 | (?x) 113 | \b(use\s+rule)\s+(\w+|\w+\*|\*)\s+(from)\s+(\w+)\s+(as)\s+(\w+|\w+\*) 114 | captures: 115 | "1": { name: keyword.control.snakemake } 116 | "2": { name: entity.name.function.snakemake.rule } 117 | "3": { name: keyword.control.snakemake } 118 | "4": { name: entity.name.type.snakemake.rule } 119 | "5": { name: keyword.control.snakemake } 120 | "6": { name: entity.name.function.snakemake.rule } 121 | 122 | userulesfrom: 123 | match: > 124 | (?x) 125 | \b(use\s+rule)\s+(\w+|\w+\*|\*)\s+(from)\s+(\w+) 126 | captures: 127 | "1": { name: keyword.control.snakemake } 128 | "2": { name: entity.name.function.snakemake.rule } 129 | "3": { name: keyword.control.snakemake } 130 | "4": { name: entity.name.type.snakemake.rule } 131 | 132 | ruleparams: 133 | match: > 134 | (?x) 135 | ^\s* # Leading whitespace 136 | ({{ruleparams}}) # Keywords 137 | : # Ending in colon 138 | captures: 139 | "1": { name: keyword.control.snakemake.ruleparam } 140 | 141 | rulerunparams: 142 | match: > 143 | (?x) 144 | ^\s* # Leading whitespace 145 | ({{rulerunparams}}) # Keywords 146 | : # Ending in colon 147 | captures: 148 | "1": { name: keyword.control.snakemake.rulerunparam } 149 | moduleparams: 150 | match: > 151 | (?x) 152 | ^\s* # Leading whitespace 153 | ({{moduleparams}}) # Keywords 154 | : # Ending in colon 155 | captures: 156 | "1": { name: keyword.control.snakemake.moduleparam } 157 | 158 | classes: 159 | match: \b({{classes}})\b(?!\s*=) 160 | captures: 161 | "1": { name: entity.name.type.class.snakemake } 162 | 163 | objects: 164 | match: \b({{objects}})\b(?!\s*=) 165 | captures: 166 | "1": { name: entity.name.type.class.snakemake } 167 | 168 | ruleargargs: 169 | match: \b({{ruleargs}})\s*\.\s*([A-Za-z_]+)\b(?!\s*=) 170 | captures: 171 | "1": { name: entity.name.variable.snakemake } 172 | "2": { name: entity.name.variable.snakemake } 173 | 174 | ruleargs: 175 | match: \b({{ruleargs}})\b(?!\s*=) 176 | captures: 177 | "1": { name: entity.name.variable.snakemake } 178 | 179 | functions: 180 | match: \b({{functions}})\b(?!\s*=) 181 | captures: 182 | "1": { name: support.function.builtin.snakemake } 183 | 184 | shell_block: 185 | begin: ^\s+shell:\s*\n*\s*\"\"\" 186 | end: \"\"\" 187 | patterns: 188 | - include: source.shell 189 | -------------------------------------------------------------------------------- /syntaxes/snakemake.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Snakemake", 3 | "scopeName": "source.python.snakemake", 4 | "fileTypes": [ 5 | "Snakefile", 6 | "smk" 7 | ], 8 | "patterns": [ 9 | { 10 | "include": "#quotessmall" 11 | }, 12 | { 13 | "include": "#quotesmid" 14 | }, 15 | { 16 | "include": "#quotesbig" 17 | }, 18 | { 19 | "include": "#configs" 20 | }, 21 | { 22 | "include": "#rules" 23 | }, 24 | { 25 | "include": "#modules" 26 | }, 27 | { 28 | "include": "#useruleas" 29 | }, 30 | { 31 | "include": "#userulefromas" 32 | }, 33 | { 34 | "include": "#userulesfrom" 35 | }, 36 | { 37 | "include": "#ruleparams" 38 | }, 39 | { 40 | "include": "#rulerunparams" 41 | }, 42 | { 43 | "include": "#moduleparams" 44 | }, 45 | { 46 | "include": "#classes" 47 | }, 48 | { 49 | "include": "#object" 50 | }, 51 | { 52 | "include": "#ruleargargs" 53 | }, 54 | { 55 | "include": "#ruleargs" 56 | }, 57 | { 58 | "include": "#functions" 59 | }, 60 | { 61 | "include": "source.python" 62 | } 63 | ], 64 | "repository": { 65 | "quotessmall": { 66 | "begin": "\\(", 67 | "end": "\\)", 68 | "patterns": [ 69 | { 70 | "include": "#quotessmall" 71 | }, 72 | { 73 | "include": "#quotesmid" 74 | }, 75 | { 76 | "include": "#quotesbig" 77 | }, 78 | { 79 | "include": "#classes" 80 | }, 81 | { 82 | "include": "#object" 83 | }, 84 | { 85 | "include": "#ruleargargs" 86 | }, 87 | { 88 | "include": "#ruleargs" 89 | }, 90 | { 91 | "include": "#functions" 92 | }, 93 | { 94 | "include": "source.python" 95 | } 96 | ] 97 | }, 98 | "quotesmid": { 99 | "begin": "\\[", 100 | "end": "\\]", 101 | "patterns": [ 102 | { 103 | "include": "#quotessmall" 104 | }, 105 | { 106 | "include": "#quotesmid" 107 | }, 108 | { 109 | "include": "#quotesbig" 110 | }, 111 | { 112 | "include": "#classes" 113 | }, 114 | { 115 | "include": "#object" 116 | }, 117 | { 118 | "include": "#ruleargargs" 119 | }, 120 | { 121 | "include": "#ruleargs" 122 | }, 123 | { 124 | "include": "#functions" 125 | }, 126 | { 127 | "include": "source.python" 128 | } 129 | ] 130 | }, 131 | "quotesbig": { 132 | "begin": "\\{", 133 | "end": "\\}", 134 | "patterns": [ 135 | { 136 | "include": "#quotessmall" 137 | }, 138 | { 139 | "include": "#quotesmid" 140 | }, 141 | { 142 | "include": "#quotesbig" 143 | }, 144 | { 145 | "include": "#classes" 146 | }, 147 | { 148 | "include": "#object" 149 | }, 150 | { 151 | "include": "#ruleargargs" 152 | }, 153 | { 154 | "include": "#ruleargs" 155 | }, 156 | { 157 | "include": "#functions" 158 | }, 159 | { 160 | "include": "source.python" 161 | } 162 | ] 163 | }, 164 | "configs": { 165 | "match": "(?x)\n ^\\s* # Leading whitespace\n (envvars|include|workdir|configfile|pepfile|pepschema|report|ruleorder|localrules|onsuccess|onerror|onstart|wildcard_constraints|singularity|container|containerized|conda|scattergather|inputflags|outputflags|storage|resource_scopes) # Keywords\n : # Ending in colon\n", 166 | "captures": { 167 | "1": { 168 | "name": "keyword.control.snakemake.config" 169 | } 170 | } 171 | }, 172 | "rules": { 173 | "match": "(?x)\n ^\\s* # Leading whitespace\n (checkpoint|rule) # Keywords\n (?:\\s+(\\w+))? # Optional rule name\n : # Ending in colon\n", 174 | "captures": { 175 | "1": { 176 | "name": "keyword.control.snakemake" 177 | }, 178 | "2": { 179 | "name": "entity.name.function.snakemake.rule" 180 | } 181 | } 182 | }, 183 | "modules": { 184 | "match": "(?x)\n ^\\s* # Leading whitespace\n (module|subworkflow) # Keywords\n (?:\\s+(\\w+))? # Optional rule name\n : # Ending in colon\n", 185 | "captures": { 186 | "1": { 187 | "name": "keyword.control.snakemake" 188 | }, 189 | "2": { 190 | "name": "entity.name.type.snakemake.rule" 191 | } 192 | } 193 | }, 194 | "useruleas": { 195 | "match": "(?x)\n \\b(use\\s+rule)\\s+(\\w+)\\s+(as)\\s+(\\w+)\\s+(with)\n : # Ending in colon\n", 196 | "captures": { 197 | "1": { 198 | "name": "keyword.control.snakemake" 199 | }, 200 | "2": { 201 | "name": "entity.name.function.snakemake.rule" 202 | }, 203 | "3": { 204 | "name": "keyword.control.snakemake" 205 | }, 206 | "4": { 207 | "name": "entity.name.function.snakemake.rule" 208 | }, 209 | "5": { 210 | "name": "keyword.control.snakemake" 211 | } 212 | } 213 | }, 214 | "userulesfromas": { 215 | "match": "(?x)\n \\b(use\\s+rule)\\s+(\\w+|\\w+\\*|\\*)\\s+(from)\\s+(\\w+)\\s+(as)\\s+(\\w+|\\w+\\*)\n", 216 | "captures": { 217 | "1": { 218 | "name": "keyword.control.snakemake" 219 | }, 220 | "2": { 221 | "name": "entity.name.function.snakemake.rule" 222 | }, 223 | "3": { 224 | "name": "keyword.control.snakemake" 225 | }, 226 | "4": { 227 | "name": "entity.name.type.snakemake.rule" 228 | }, 229 | "5": { 230 | "name": "keyword.control.snakemake" 231 | }, 232 | "6": { 233 | "name": "entity.name.function.snakemake.rule" 234 | } 235 | } 236 | }, 237 | "userulesfrom": { 238 | "match": "(?x)\n \\b(use\\s+rule)\\s+(\\w+|\\w+\\*|\\*)\\s+(from)\\s+(\\w+)\n", 239 | "captures": { 240 | "1": { 241 | "name": "keyword.control.snakemake" 242 | }, 243 | "2": { 244 | "name": "entity.name.function.snakemake.rule" 245 | }, 246 | "3": { 247 | "name": "keyword.control.snakemake" 248 | }, 249 | "4": { 250 | "name": "entity.name.type.snakemake.rule" 251 | } 252 | } 253 | }, 254 | "ruleparams": { 255 | "match": "(?x)\n ^\\s* # Leading whitespace\n (name|input|output|params|threads|resources|retries|priority|log|message|benchmark|conda|singularity|container|containerized|envmodules|wildcard_constraints|shadow|group|cache|handover|default_target|localrule|version|container_img|is_containerized|shellcmd|norun|conda_env|env_modules|shadow_depth|docstring|path_modifier) # Keywords\n : # Ending in colon\n", 256 | "captures": { 257 | "1": { 258 | "name": "keyword.control.snakemake.ruleparam" 259 | } 260 | } 261 | }, 262 | "rulerunparams": { 263 | "match": "(?x)\n ^\\s* # Leading whitespace\n (run|shell|script|notebook|wrapper|template_engine|cwl) # Keywords\n : # Ending in colon\n", 264 | "captures": { 265 | "1": { 266 | "name": "keyword.control.snakemake.rulerunparam" 267 | } 268 | } 269 | }, 270 | "moduleparams": { 271 | "match": "(?x)\n ^\\s* # Leading whitespace\n (name|snakefile|meta_wrapper|config|skip_validation|replace_prefix|prefix) # Keywords\n : # Ending in colon\n", 272 | "captures": { 273 | "1": { 274 | "name": "keyword.control.snakemake.moduleparam" 275 | } 276 | } 277 | }, 278 | "classes": { 279 | "match": "\\b(Path|WorkflowError)\\b(?!\\s*=)", 280 | "captures": { 281 | "1": { 282 | "name": "entity.name.type.class.snakemake" 283 | } 284 | } 285 | }, 286 | "objects": { 287 | "match": "\\b(snakemake|rules|workflow|checkpoints|storage|access|scatter|gather)\\b(?!\\s*=)", 288 | "captures": { 289 | "1": { 290 | "name": "entity.name.type.class.snakemake" 291 | } 292 | } 293 | }, 294 | "ruleargargs": { 295 | "match": "\\b(input|output|params|wildcards|threads|resources|log|config)\\s*\\.\\s*([A-Za-z_]+)\\b(?!\\s*=)", 296 | "captures": { 297 | "1": { 298 | "name": "entity.name.variable.snakemake" 299 | }, 300 | "2": { 301 | "name": "entity.name.variable.snakemake" 302 | } 303 | } 304 | }, 305 | "ruleargs": { 306 | "match": "\\b(input|output|params|wildcards|threads|resources|log|config)\\b(?!\\s*=)", 307 | "captures": { 308 | "1": { 309 | "name": "entity.name.variable.snakemake" 310 | } 311 | } 312 | }, 313 | "functions": { 314 | "match": "\\b(shell|github|gitlab|gitfile|from_queue|protected|temp|temporary|ancient|directory|expand|glob_wildcards|flag|touch|unpack|local|pipe|service|repeat|report|multiext|ensure|update|before_update|lookup|evaluate|branch|collect|exists|subpath|parse_input|extract_checksum|flatten)\\b(?!\\s*=)", 315 | "captures": { 316 | "1": { 317 | "name": "support.function.builtin.snakemake" 318 | } 319 | } 320 | }, 321 | "shell_block": { 322 | "begin": "^\\s+shell:\\s*\\n*\\s*\\\"\\\"\\\"", 323 | "end": "\\\"\\\"\\\"", 324 | "patterns": [ 325 | { 326 | "include": "source.shell" 327 | } 328 | ] 329 | } 330 | } 331 | } 332 | --------------------------------------------------------------------------------