Skip to content

Commit cacacae

Browse files
committed
feat(nvim): Add queries for nextflow
1 parent ef95932 commit cacacae

4 files changed

Lines changed: 469 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
;; Nextflow treesitter fold queries
2+
3+
;; Fold process blocks
4+
(process_declaration
5+
body: (block) @fold)
6+
7+
;; Fold workflow blocks
8+
(workflow_declaration
9+
body: (block) @fold)
10+
11+
;; Fold function blocks
12+
(function_declaration
13+
body: (block) @fold)
14+
15+
;; Fold class and interface blocks
16+
(class_declaration
17+
body: (class_body) @fold)
18+
(interface_declaration
19+
body: (interface_body) @fold)
20+
21+
;; Fold method blocks
22+
(method_declaration
23+
body: (block) @fold)
24+
25+
;; Fold closure blocks
26+
(closure
27+
body: (block) @fold)
28+
29+
;; Fold control flow blocks
30+
(if_statement
31+
then: (block) @fold)
32+
(if_statement
33+
else: (block) @fold)
34+
(while_statement
35+
body: (block) @fold)
36+
(for_statement
37+
body: (block) @fold)
38+
(try_statement
39+
body: (block) @fold)
40+
(catch_clause
41+
body: (block) @fold)
42+
(finally_clause
43+
body: (block) @fold)
44+
45+
;; Fold multi-line comments
46+
(block_comment) @fold
47+
48+
;; Fold multiline strings
49+
(multiline_string_literal) @fold
50+
51+
;; Fold array and map literals
52+
(array_literal) @fold
53+
(map_literal) @fold
54+
55+
;; Fold switch statements
56+
(switch_statement
57+
body: (switch_block) @fold)
58+
59+
;; Fold case blocks
60+
(case_clause
61+
body: (block) @fold)
Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
;; Nextflow treesitter highlight queries
2+
;; Based on the nextflow-io/tree-sitter-nextflow grammar
3+
4+
;; Keywords
5+
[
6+
"process"
7+
"workflow"
8+
"function"
9+
"include"
10+
"from"
11+
"params"
12+
"nextflow"
13+
"manifest"
14+
"docker"
15+
"singularity"
16+
"conda"
17+
"env"
18+
"executor"
19+
"queue"
20+
"memory"
21+
"cpus"
22+
"time"
23+
"disk"
24+
"attempt"
25+
"tag"
26+
"publishDir"
27+
"cache"
28+
"container"
29+
"module"
30+
"conda"
31+
"spack"
32+
"beforeScript"
33+
"afterScript"
34+
"shell"
35+
"script"
36+
"exec"
37+
"stub"
38+
"when"
39+
"input"
40+
"output"
41+
"take"
42+
"emit"
43+
"main"
44+
] @keyword
45+
46+
;; Operators
47+
[
48+
"="
49+
"+="
50+
"-="
51+
"*="
52+
"/="
53+
"%="
54+
"=="
55+
"!="
56+
"<"
57+
"<="
58+
">"
59+
">="
60+
"&&"
61+
"||"
62+
"!"
63+
"+"
64+
"-"
65+
"*"
66+
"/"
67+
"%"
68+
"~"
69+
"=~"
70+
"!~"
71+
"<<"
72+
">>"
73+
"&"
74+
"|"
75+
"^"
76+
"?"
77+
":"
78+
"?:"
79+
"?."
80+
"*."
81+
".&"
82+
".@"
83+
"*.@"
84+
"++"
85+
"--"
86+
"**"
87+
"<=>"
88+
"in"
89+
"as"
90+
"instanceof"
91+
] @operator
92+
93+
;; Punctuation
94+
[
95+
"("
96+
")"
97+
"["
98+
"]"
99+
"{"
100+
"}"
101+
";"
102+
","
103+
"."
104+
"->"
105+
"=>"
106+
] @punctuation.delimiter
107+
108+
;; Literals
109+
(boolean_literal) @boolean
110+
(null_literal) @constant.builtin
111+
(number_literal) @number
112+
(string_literal) @string
113+
(gstring_literal) @string
114+
(multiline_string_literal) @string
115+
116+
;; Regular expressions
117+
(regex_literal) @string.regex
118+
119+
;; Comments
120+
(line_comment) @comment
121+
(block_comment) @comment
122+
123+
;; Identifiers
124+
(identifier) @variable
125+
126+
;; Function calls
127+
(method_call
128+
object: (identifier) @variable
129+
method: (identifier) @function.method)
130+
131+
(function_call
132+
function: (identifier) @function.call)
133+
134+
;; Type annotations
135+
(type_annotation
136+
type: (identifier) @type)
137+
138+
;; Channel operations
139+
(method_call
140+
object: (identifier) @variable (#match? @variable "^Channel$")
141+
method: (identifier) @function.builtin)
142+
143+
;; Process directives
144+
(assignment
145+
left: (identifier) @keyword.directive
146+
(#match? @keyword.directive "^(cpus|memory|time|disk|queue|container|publishDir|tag|cache|executor|conda|module|beforeScript|afterScript|shell|script|exec|stub|when|input|output)$"))
147+
148+
;; Variable definitions
149+
(assignment
150+
left: (identifier) @variable.definition)
151+
152+
;; Parameters
153+
(params_declaration
154+
(identifier) @parameter)
155+
156+
;; Include statements
157+
(include_statement
158+
module: (string_literal) @string.special)
159+
160+
;; Process names
161+
(process_declaration
162+
name: (identifier) @function.definition)
163+
164+
;; Workflow names
165+
(workflow_declaration
166+
name: (identifier) @function.definition)
167+
168+
;; Function names
169+
(function_declaration
170+
name: (identifier) @function.definition)
171+
172+
;; Groovy-style closures
173+
(closure) @function.definition
174+
175+
;; Error handling
176+
(try_statement) @keyword
177+
(catch_clause) @keyword
178+
(finally_clause) @keyword
179+
(throw_statement) @keyword
180+
181+
;; Control flow
182+
[
183+
"if"
184+
"else"
185+
"while"
186+
"for"
187+
"do"
188+
"switch"
189+
"case"
190+
"default"
191+
"break"
192+
"continue"
193+
"return"
194+
"try"
195+
"catch"
196+
"finally"
197+
"throw"
198+
] @keyword.control
199+
200+
;; Built-in types
201+
[
202+
"int"
203+
"long"
204+
"float"
205+
"double"
206+
"boolean"
207+
"char"
208+
"byte"
209+
"short"
210+
"String"
211+
"def"
212+
"var"
213+
"void"
214+
] @type.builtin
215+
216+
;; Access modifiers
217+
[
218+
"public"
219+
"private"
220+
"protected"
221+
"static"
222+
"final"
223+
"abstract"
224+
"synchronized"
225+
"volatile"
226+
"transient"
227+
"native"
228+
"strictfp"
229+
] @keyword.modifier
230+
231+
;; Annotations
232+
(annotation
233+
name: (identifier) @attribute)
234+
235+
;; Class and interface definitions
236+
(class_declaration
237+
name: (identifier) @type.definition)
238+
(interface_declaration
239+
name: (identifier) @type.definition)
240+
241+
;; Import statements
242+
(import_statement) @keyword.import
243+
244+
;; Package declarations
245+
(package_declaration) @keyword.import
246+
247+
;; Special Nextflow variables
248+
((identifier) @constant.builtin
249+
(#match? @constant.builtin "^(params|workflow|nextflow|launchDir|workDir|projectDir|baseDir)$"))
250+
251+
;; File paths and globs
252+
(string_literal) @string.special
253+
(#match? @string.special "\\*\\*?|\\?|\\[.*\\]")
254+
255+
;; Environment variables
256+
(gstring_literal
257+
(gstring_expression
258+
(identifier) @variable.builtin
259+
(#match? @variable.builtin "^[A-Z_][A-Z0-9_]*$")))
260+
261+
;; Special method calls
262+
(method_call
263+
method: (identifier) @function.builtin
264+
(#match? @function.builtin "^(collect|map|filter|flatten|unique|groupTuple|combine|join|mix|merge|splitText|splitCsv|splitFasta|view|subscribe|into|set)$"))
265+
266+
;; Error highlighting for common mistakes
267+
(ERROR) @error
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
;; Nextflow treesitter indent queries
2+
3+
[
4+
(process_declaration)
5+
(workflow_declaration)
6+
(function_declaration)
7+
(class_declaration)
8+
(interface_declaration)
9+
(method_declaration)
10+
(closure)
11+
(block)
12+
(class_body)
13+
(interface_body)
14+
(switch_block)
15+
(if_statement)
16+
(while_statement)
17+
(for_statement)
18+
(try_statement)
19+
(catch_clause)
20+
(finally_clause)
21+
(case_clause)
22+
(array_literal)
23+
(map_literal)
24+
(argument_list)
25+
(parameter_list)
26+
] @indent.begin
27+
28+
[
29+
"}"
30+
"]"
31+
")"
32+
] @indent.end
33+
34+
[
35+
(line_comment)
36+
(block_comment)
37+
] @indent.ignore

0 commit comments

Comments
 (0)