Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/go/injections.scm')
| -rw-r--r-- | runtime/queries/go/injections.scm | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/runtime/queries/go/injections.scm b/runtime/queries/go/injections.scm index 48dfae36..8dd5c3c8 100644 --- a/runtime/queries/go/injections.scm +++ b/runtime/queries/go/injections.scm @@ -39,3 +39,48 @@ (interpreted_string_literal) ] @injection.content (#set! injection.language "regex"))) + +; https://pkg.go.dev/fmt#Printf +; https://pkg.go.dev/fmt#Sprintf +; https://pkg.go.dev/fmt#Scanf +((call_expression + function: (selector_expression + operand: (identifier) @_module + field: (field_identifier) @_func) + arguments: (argument_list + . (interpreted_string_literal) @injection.content)) + (#eq? @_module "fmt") + (#any-of? @_func "Printf" "Sprintf" "Scanf") + (#set! injection.language "go-format-string")) + +; https://pkg.go.dev/fmt#Fprintf +; https://pkg.go.dev/fmt#Fscanf +; https://pkg.go.dev/fmt#Sscanf +((call_expression + function: (selector_expression + operand: (identifier) @_module + field: (field_identifier) @_func) + arguments: (argument_list + ; [(identifier) (interpreted_string_literal)] + (_) + ; (identifier) + . + (interpreted_string_literal) @injection.content)) + (#eq? @_module "fmt") + (#any-of? @_func "Fprintf" "Fscanf" "Sscanf") + (#set! injection.language "go-format-string")) + +; https://pkg.go.dev/log#Printf +; https://pkg.go.dev/log#Fatalf +; https://pkg.go.dev/log#Panicf +; https://pkg.go.dev/log#Logger.Printf +; https://pkg.go.dev/log#Logger.Fatalf +; https://pkg.go.dev/log#Logger.Panicf +((call_expression + function: (selector_expression + operand: (identifier) + field: (field_identifier) @_func) + arguments: (argument_list + . (interpreted_string_literal) @injection.content)) + (#any-of? @_func "Printf" "Fatalf" "Panicf") + (#set! injection.language "go-format-string")) |