From 207c0e389968888ed1a1fa064e9d2a100b60cf20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Plagborg=20Bak=20S=C3=B8rensen?= <57013304+kpbaks@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:23:53 +0200 Subject: [PATCH] feat: inject `jq` into `jq "..."` string literals in common shells (#14253) --- runtime/queries/bash/injections.scm | 8 ++++++++ runtime/queries/fish/injections.scm | 5 +++++ runtime/queries/nu/injections.scm | 7 ++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/runtime/queries/bash/injections.scm b/runtime/queries/bash/injections.scm index d6771e44..ce25a6c0 100644 --- a/runtime/queries/bash/injections.scm +++ b/runtime/queries/bash/injections.scm @@ -9,3 +9,11 @@ ((regex) @injection.content (#set! injection.language "regex")) + +(command + name: (command_name (word) @_command (#any-of? @_command "jq" "jaq")) + argument: [ + (raw_string) @injection.content + (string (string_content) @injection.content) + ] + (#set! injection.language "jq")) diff --git a/runtime/queries/fish/injections.scm b/runtime/queries/fish/injections.scm index 321c90ad..3378c14a 100644 --- a/runtime/queries/fish/injections.scm +++ b/runtime/queries/fish/injections.scm @@ -1,2 +1,7 @@ ((comment) @injection.content (#set! injection.language "comment")) + +(command + name: (word) @_command (#any-of? @_command "jq" "jaq") + argument: [(double_quote_string) (single_quote_string)] @injection.content + (#set! injection.language "jq")) diff --git a/runtime/queries/nu/injections.scm b/runtime/queries/nu/injections.scm index 30804d65..690ff9a8 100644 --- a/runtime/queries/nu/injections.scm +++ b/runtime/queries/nu/injections.scm @@ -1,2 +1,7 @@ ((comment) @injection.content - (#set! injection.language "comment")) \ No newline at end of file + (#set! injection.language "comment")) + +(command + head: (cmd_identifier) @_command (#any-of? @_command "jq" "jaq") + arg: (val_string) @injection.content + (#set! injection.language "jq")) -- 2.51.2