Skip to content

Commit

Permalink
fix(nvim): go/injections.scm
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Sep 1, 2023
1 parent 808cf27 commit 74cb52a
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions modules/neovim/config/after/queries/go/injections.scm
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
; extends

; inject sql into any const string with word query in the name
; e.g. const query = `SELECT * FROM users WHERE name = 'John'`;

(const_spec
name: (identifier) @_name (#match? @_name "[Qq]uery")
value: (expression_list
(raw_string_literal) @sql)
(#offset! @sql 0 1 0 -1))
(raw_string_literal) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "sql"))

; inject sql in single line strings
(call_expression
(selector_expression
field: (field_identifier) @_field (#any-of? @_field "GetContext" "ExecContext" "SelectContext" "In"))
field: (field_identifier) @_field (#any-of? @_field "GetContext" "Get" "ExecContext" "Exec" "SelectContext" "Select" "In" "Rebind"))
(argument_list
(interpreted_string_literal) @sql)
(#offset! @sql 0 1 0 -1)) ; wtf does this do?
(raw_string_literal) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "sql")
)

; inject sql in multi line strings
(call_expression
(selector_expression
field: (field_identifier) @_field (#any-of? @_field "GetContext" "ExecContext" "SelectContext" "In"))
field: (field_identifier) @_field (#any-of? @_field "GetContext" "Get" "ExecContext" "Exec" "SelectContext" "Select" "In" "Rebind"))
(argument_list
(raw_string_literal) @sql)
(#offset! @sql 0 1 0 -1)) ; wtf does this do?
(interpreted_string_literal) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "sql")
)

0 comments on commit 74cb52a

Please sign in to comment.