@@ -6,6 +6,8 @@
6 (indented_string_expression (string_fragment) @injection.content))
6 (indented_string_expression (string_fragment) @injection.content))
7 (#set! injection.combined))
7 (#set! injection.combined))
9+; Common attribute keys corresponding to scripts,
10+; such as those of stdenv.mkDerivation.
10 attrpath: (attrpath (identifier) @_path)
12 attrpath: (attrpath (identifier) @_path)
11 expression: (indented_string_expression
13 expression: (indented_string_expression
@@ -14,6 +16,25 @@
14 (#set! injection.language "bash")
16 (#set! injection.language "bash")
15 (#set! injection.combined))
17 (#set! injection.combined))
19+; builtins.{match,split} regex str
20+; Example: nix/tests/lang/eval-okay-regex-{match,split}.nix
23+ argument: (indented_string_expression (string_fragment) @injection.content))
24+ (#match? @_func "(^|\\.)match|split$")
25+ (#set! injection.language "regex")
26+ (#set! injection.combined))
28+; builtins.fromJSON json
29+; Example: nix/tests/lang/eval-okay-fromjson.nix
32+ argument: (indented_string_expression (string_fragment) @injection.content))
33+ (#match? @_func "(^|\\.)fromJSON$")
34+ (#set! injection.language "json")
35+ (#set! injection.combined))
37+; trivial-builders.nix pkgs.writeShellScript[Bin] name content
17((apply_expression
38((apply_expression
18 function: (apply_expression function: (_) @_func)
39 function: (apply_expression function: (_) @_func)
19 argument: (indented_string_expression (string_fragment) @injection.content))
40 argument: (indented_string_expression (string_fragment) @injection.content))
@@ -21,6 +42,8 @@
21 (#set! injection.language "bash")
42 (#set! injection.language "bash")
22 (#set! injection.combined))
43 (#set! injection.combined))
45+; trivial-builders.nix, aliases.nix
46+; pkgs.runCommand[[No]CC][Local] name attrs content
24(apply_expression
47(apply_expression
25 (apply_expression
48 (apply_expression
26 function: (apply_expression
49 function: (apply_expression
@@ -30,6 +53,7 @@
30 (#set! injection.language "bash")
53 (#set! injection.language "bash")
31 (#set! injection.combined))
54 (#set! injection.combined))
56+; trivial-builders.nix pkgs.writeShellApplication { text = content; }
33(apply_expression
57(apply_expression
34 function: ((_) @_func)
58 function: ((_) @_func)
35 argument: (_ (_)* (_ (_)* (binding
59 argument: (_ (_)* (_ (_)* (binding
@@ -40,3 +64,89 @@
40 (#match? @_path "^text$")
64 (#match? @_path "^text$")
41 (#set! injection.language "bash")
65 (#set! injection.language "bash")
42 (#set! injection.combined))
66 (#set! injection.combined))
68+; trivial-builders.nix pkgs.writeCBin name content
70+ function: (apply_expression function: (_) @_func)
71+ argument: (indented_string_expression (string_fragment) @injection.content))
72+ (#match? @_func "(^|\\.)writeC(Bin)?$")
73+ (#set! injection.language "c")
74+ (#set! injection.combined))
76+; pkgs.writers.* usage examples: nixpkgs/pkgs/build-support/writers/test.nix
78+; pkgs.writers.write{Bash,Dash}[Bin] name content
80+ function: (apply_expression function: (_) @_func)
81+ argument: (indented_string_expression (string_fragment) @injection.content))
82+ (#match? @_func "(^|\\.)write[BD]ash(Bin)?$")
83+ (#set! injection.language "bash")
84+ (#set! injection.combined))
86+; pkgs.writers.writeFish[Bin] name content
88+ function: (apply_expression function: (_) @_func)
89+ argument: (indented_string_expression (string_fragment) @injection.content))
90+ (#match? @_func "(^|\\.)writeFish(Bin)?$")
91+ (#set! injection.language "fish")
92+ (#set! injection.combined))
94+; pkgs.writers.writeRust[Bin] name attrs content
97+ function: (apply_expression
98+ function: ((_) @_func)))
99+ argument: (indented_string_expression (string_fragment) @injection.content)
100+ (#match? @_func "(^|\\.)writeRust(Bin)?$")
101+ (#set! injection.language "rust")
102+ (#set! injection.combined))
104+; pkgs.writers.writeHaskell[Bin] name attrs content
107+ function: (apply_expression
108+ function: ((_) @_func)))
109+ argument: (indented_string_expression (string_fragment) @injection.content)
110+ (#match? @_func "(^|\\.)writeHaskell(Bin)?$")
111+ (#set! injection.language "haskell")
112+ (#set! injection.combined))
114+; pkgs.writers.writeJS[Bin] name attrs content
117+ function: (apply_expression
118+ function: ((_) @_func)))
119+ argument: (indented_string_expression (string_fragment) @injection.content)
120+ (#match? @_func "(^|\\.)writeJS(Bin)?$")
121+ (#set! injection.language "javascript")
122+ (#set! injection.combined))
124+; pkgs.writers.writePerl[Bin] name attrs content
127+ function: (apply_expression
128+ function: ((_) @_func)))
129+ argument: (indented_string_expression (string_fragment) @injection.content)
130+ (#match? @_func "(^|\\.)writePerl(Bin)?$")
131+ (#set! injection.language "perl")
132+ (#set! injection.combined))
134+; pkgs.writers.write{Python,PyPy}{2,3}[Bin] name attrs content
137+ function: (apply_expression
138+ function: ((_) @_func)))
139+ argument: (indented_string_expression (string_fragment) @injection.content)
140+ (#match? @_func "(^|\\.)write(Python|PyPy)[23](Bin)?$")
141+ (#set! injection.language "python")
142+ (#set! injection.combined))
144+; pkgs.writers.writeFSharp[Bin] name content
145+; No query available for f-sharp as of the time of writing
146+; See: https://github.com/helix-editor/helix/issues/4943
148+; function: (apply_expression function: (_) @_func)
149+; argument: (indented_string_expression (string_fragment) @injection.content))
150+; (#match? @_func "(^|\\.)writeFSharp(Bin)?$")
151+; (#set! injection.language "f-sharp")
152+; (#set! injection.combined))