Unnamed repository; edit this file 'description' to name the repository.
Highlight $ template literals as shell commands (#12751)
uncenter 2025-02-02
parent 3061634 · commit e70f883
-rw-r--r--runtime/queries/ecma/injections.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/runtime/queries/ecma/injections.scm b/runtime/queries/ecma/injections.scm
index 09cca441..72ad31da 100644
--- a/runtime/queries/ecma/injections.scm
+++ b/runtime/queries/ecma/injections.scm
@@ -10,6 +10,18 @@
arguments: (template_string) @injection.content
(#any-of? @injection.language "html" "css" "json" "sql" "js" "ts" "bash"))
+; Parse the contents of $ template literals as shell commands
+
+(call_expression
+ function: [
+ (identifier) @_template_function_name
+ (member_expression
+ property: (property_identifier) @_template_function_name)
+ ]
+ arguments: (template_string) @injection.content
+ (#eq? @_template_function_name "$")
+ (#set! injection.language "bash"))
+
; Parse the contents of gql template literals
((call_expression