From eb3911d052fd52688e4c617296881791e04eef28 Mon Sep 17 00:00:00 2001 From: Sam <30577766+Samasaur1@users.noreply.github.com> Date: Sat, 24 Jan 2026 18:48:20 -0700 Subject: [PATCH] fix(nix): match writers in nested attrpaths The current Nix injections don't mark this as bash: ```nix pkgs.writers.writeBash "" '' echo Hello, world! '' ``` but do mark this as bash: ```nix writers.............................writeBash "" '' echo hi '' ``` (and similar for other languages). Note that in order to solve this issue, I had to swap from Lua patterns to Vim regexps, which I know is less efficient. Unfortunately Lua patterns don't let you use modifiers on groups, so I swapped. --- runtime/queries/nix/injections.scm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/queries/nix/injections.scm b/runtime/queries/nix/injections.scm index 718a9c1c5..b847fba42 100644 --- a/runtime/queries/nix/injections.scm +++ b/runtime/queries/nix/injections.scm @@ -136,7 +136,7 @@ ((string_fragment) @injection.content (#set! injection.language "bash"))) ]) - (#lua-match? @_func "^%a*%.*writeBash%a*$") + (#match? @_func "^([a-zA-Z]+.)*writeBash[a-zA-Z]*$") (#set! injection.combined)) ((apply_expression @@ -150,7 +150,7 @@ ((string_fragment) @injection.content (#set! injection.language "bash"))) ]) - (#lua-match? @_func "^%a*%.*writeDash%a*$") + (#match? @_func "^([a-zA-Z]+.)*writeDash[a-zA-Z]*$") (#set! injection.combined)) ((apply_expression @@ -178,7 +178,7 @@ ((string_fragment) @injection.content (#set! injection.language "fish"))) ]) - (#lua-match? @_func "^%a*%.*writeFish%a*$") + (#match? @_func "^([a-zA-Z]+.)*writeFish[a-zA-Z]*$") (#set! injection.combined)) ((apply_expression @@ -193,7 +193,7 @@ ((string_fragment) @injection.content (#set! injection.language "haskell"))) ]) - (#lua-match? @_func "^%a*%.*writeHaskell%a*$") + (#match? @_func "^([a-zA-Z]+.)*writeHaskell[a-zA-Z]*$") (#set! injection.combined)) ((apply_expression @@ -207,7 +207,7 @@ ((string_fragment) @injection.content (#set! injection.language "javascript"))) ]) - (#lua-match? @_func "^%a*%.*writeJS%a*$") + (#match? @_func "^([a-zA-Z]+.)*writeJS[a-zA-Z]*$") (#set! injection.combined)) ((apply_expression @@ -221,7 +221,7 @@ ((string_fragment) @injection.content (#set! injection.language "perl"))) ]) - (#lua-match? @_func "^%a*%.*writePerl%a*$") + (#match? @_func "^([a-zA-Z]+.)*writePerl[a-zA-Z]*$") (#set! injection.combined)) ((apply_expression @@ -235,7 +235,7 @@ ((string_fragment) @injection.content (#set! injection.language "python"))) ]) - (#lua-match? @_func "^%a*%.*writePy%a*%d*%a*$") + (#match? @_func "^([a-zA-Z]+.)*writePy[a-zA-Z]*[0-9]*[a-zA-Z]*$") (#set! injection.combined)) ((apply_expression @@ -248,7 +248,7 @@ ((string_fragment) @injection.content (#set! injection.language "rust"))) ]) - (#lua-match? @_func "^%a*%.*writeRust%a*$") + (#match? @_func "^([a-zA-Z]+.)*writeRust[a-zA-Z]*$") (#set! injection.combined)) ; (runTest) testScript