From 06989a933e24d1ae5c140e3934545218a1c1b48f Mon Sep 17 00:00:00 2001 From: figsoda Date: Sat, 3 Dec 2022 16:33:50 -0500 Subject: [PATCH] injections(nix): combine injections to work better with interpolations --- queries/nix/highlights.scm | 3 ++- queries/nix/injections.scm | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/queries/nix/highlights.scm b/queries/nix/highlights.scm index bce901a47..86b497e9f 100644 --- a/queries/nix/highlights.scm +++ b/queries/nix/highlights.scm @@ -33,7 +33,8 @@ (comment) @comment ; strings -[ (string_expression) (indented_string_expression) ] @string +([ (string_expression) (indented_string_expression) ] + (#set! "priority" 99)) @string ; paths and URLs [ (path_expression) (spath_expression) (uri_expression) ] @string.special diff --git a/queries/nix/injections.scm b/queries/nix/injections.scm index 9765033a4..3d965289a 100644 --- a/queries/nix/injections.scm +++ b/queries/nix/injections.scm @@ -7,6 +7,7 @@ (indented_string_expression (string_fragment) @regex) ] (#match? @_func "(^|\\.)match$")) + @combined (binding attrpath: (attrpath (identifier) @_path) @@ -15,6 +16,7 @@ (indented_string_expression (string_fragment) @bash) ] (#match? @_path "(^\\w*Phase|(pre|post)\\w*|(.*\\.)?\\w*([sS]cript|[hH]ook)|(.*\\.)?startup)$")) + @combined (apply_expression function: (_) @_func @@ -26,6 +28,7 @@ ]))) (#match? @_func "(^|\\.)writeShellApplication$") (#match? @_path "^text$")) + @combined (apply_expression function: (apply_expression @@ -35,6 +38,7 @@ (indented_string_expression (string_fragment) @bash) ] (#match? @_func "(^|\\.)runCommand((No)?CC)?(Local)?$")) + @combined ((apply_expression function: (apply_expression function: (_) @_func) @@ -43,6 +47,7 @@ (indented_string_expression (string_fragment) @bash) ]) (#match? @_func "(^|\\.)write(Bash|Dash|ShellScript)(Bin)?$")) + @combined ((apply_expression function: (apply_expression function: (_) @_func) @@ -51,6 +56,7 @@ (indented_string_expression (string_fragment) @fish) ]) (#match? @_func "(^|\\.)writeFish(Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -60,6 +66,7 @@ (indented_string_expression (string_fragment) @haskell) ]) (#match? @_func "(^|\\.)writeHaskell(Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -69,6 +76,7 @@ (indented_string_expression (string_fragment) @javascript) ]) (#match? @_func "(^|\\.)writeJS(Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -78,6 +86,7 @@ (indented_string_expression (string_fragment) @perl) ]) (#match? @_func "(^|\\.)writePerl(Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -87,6 +96,7 @@ (indented_string_expression (string_fragment) @python) ]) (#match? @_func "(^|\\.)write(PyPy|Python)[23](Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -96,3 +106,4 @@ (indented_string_expression (string_fragment) @rust) ]) (#match? @_func "(^|\\.)writeRust(Bin)?$")) + @combined