aboutsummaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorosthomas <8322329+osthomas@users.noreply.github.com>2025-09-07 13:58:28 +0200
committerGitHub <noreply@github.com>2025-09-07 13:58:28 +0200
commitfee71c102c54146f90b14c89711ddbb8f95a1484 (patch)
tree50c590a933a11020180514460c7d0b1e53af2693 /runtime
parentfeat(parsers): update arduino, desktop, hurl, mlir, query, slint, snakemake, ... (diff)
downloadnvim-treesitter-fee71c102c54146f90b14c89711ddbb8f95a1484.tar
nvim-treesitter-fee71c102c54146f90b14c89711ddbb8f95a1484.tar.gz
nvim-treesitter-fee71c102c54146f90b14c89711ddbb8f95a1484.tar.bz2
nvim-treesitter-fee71c102c54146f90b14c89711ddbb8f95a1484.tar.lz
nvim-treesitter-fee71c102c54146f90b14c89711ddbb8f95a1484.tar.xz
nvim-treesitter-fee71c102c54146f90b14c89711ddbb8f95a1484.tar.zst
nvim-treesitter-fee71c102c54146f90b14c89711ddbb8f95a1484.zip
feat(snakemake): update queries (#8106)
also add indent tests
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queries/snakemake/highlights.scm8
-rw-r--r--runtime/queries/snakemake/indents.scm40
-rw-r--r--runtime/queries/snakemake/locals.scm36
3 files changed, 64 insertions, 20 deletions
diff --git a/runtime/queries/snakemake/highlights.scm b/runtime/queries/snakemake/highlights.scm
index 8781b405c..59a180c44 100644
--- a/runtime/queries/snakemake/highlights.scm
+++ b/runtime/queries/snakemake/highlights.scm
@@ -63,20 +63,20 @@ body: (_
; directive labels in wildcard context
((wildcard
(identifier) @label)
- (#any-of? @label "input" "log" "output" "params" "resources" "threads" "wildcards"))
+ (#any-of? @label "input" "jobid" "log" "output" "params" "resources" "rule" "threads" "wildcards"))
((wildcard
(attribute
object: (identifier) @label))
- (#any-of? @label "input" "log" "output" "params" "resources" "threads" "wildcards"))
+ (#any-of? @label "input" "jobid" "log" "output" "params" "resources" "rule" "threads" "wildcards"))
((wildcard
(subscript
value: (identifier) @label))
- (#any-of? @label "input" "log" "output" "params" "resources" "threads" "wildcards"))
+ (#any-of? @label "input" "jobid" "log" "output" "params" "resources" "rule" "threads" "wildcards"))
; directive labels in block context (eg. within 'run:')
((identifier) @label
- (#any-of? @label "input" "log" "output" "params" "resources" "threads" "wildcards")
+ (#any-of? @label "input" "jobid" "log" "output" "params" "resources" "rule" "threads" "wildcards")
(#has-ancestor? @label "directive")
(#has-ancestor? @label "block"))
diff --git a/runtime/queries/snakemake/indents.scm b/runtime/queries/snakemake/indents.scm
index 140b7fb3c..d4ed63992 100644
--- a/runtime/queries/snakemake/indents.scm
+++ b/runtime/queries/snakemake/indents.scm
@@ -1,12 +1,12 @@
; inherits: python
-((rule_definition) @indent.begin
- (#set! indent.immediate 1))
-
-((checkpoint_definition) @indent.begin
- (#set! indent.immediate 1))
-
-((rule_inheritance) @indent.begin
+([
+ (rule_definition)
+ (checkpoint_definition)
+ (rule_inheritance)
+ (module_definition)
+ (directive)
+] @indent.begin
(#set! indent.immediate 1))
((rule_import
@@ -14,12 +14,20 @@
":") @indent.begin
(#set! indent.immediate 1))
-((module_definition) @indent.begin
- (#set! indent.immediate 1))
-
-((directive) @indent.begin
- (#set! indent.immediate 1))
-
-; end indentation after last parameter node (no following ',')
-(directive_parameters
- (_) @indent.end .)
+; ; end indentation after last parameter node (no following ',')
+; ; accommodate different levels of nesting
+; ; see also queries/python/indents.scm: return_statement
+(directive
+ (directive_parameters
+ [
+ (_) @indent.dedent
+ (_
+ [
+ (_)
+ ")"
+ "}"
+ "]"
+ ] .) @indent.dedent
+ ]
+ . ; anchor at end: no subsequent ','
+ ))
diff --git a/runtime/queries/snakemake/locals.scm b/runtime/queries/snakemake/locals.scm
index 219f23347..8b5e7c0b4 100644
--- a/runtime/queries/snakemake/locals.scm
+++ b/runtime/queries/snakemake/locals.scm
@@ -2,3 +2,39 @@
(rule_definition
name: (identifier) @local.definition.type) @local.scope
+
+(rule_inheritance
+ alias: (as_pattern_target) @local.definition.type) @local.scope
+
+(checkpoint_definition
+ name: (identifier) @local.definition.type) @local.scope
+
+(module_definition
+ name: (identifier) @local.definition.type) @local.scope
+
+; use rule A from X
+(rule_import
+ (rule_import_list
+ (identifier) @local.definition.import)
+ .
+ module_name: (identifier) .) @local.scope
+
+; use rule A from X as A_fromX
+; use rule A from X as *_fromX
+; use rule * from X as *_fromX
+(rule_import
+ alias: (as_pattern_target) @local.definition.import .) @local.scope
+
+; use rule A from X with:
+(rule_import
+ (rule_import_list
+ (identifier) @local.definition.type)
+ .
+ module_name: (identifier)
+ .
+ "with") @local.scope
+
+; use rule A from X as Y with:
+(rule_import
+ alias: (as_pattern_target) @local.definition.type
+ "with") @local.scope