aboutsummaryrefslogtreecommitdiffstats
path: root/queries/ecma
diff options
context:
space:
mode:
authorPham Huy Hoang <hoangtun0810@gmail.com>2023-05-03 19:07:59 +0900
committerChristian Clason <c.clason@uni-graz.at>2023-08-12 17:34:15 +0200
commit78b54eb7f6a9956d25a3911fa0dfd0cabfe2a4c5 (patch)
tree87bc9ffd574b406ceaeb4ea4c32290e66145f587 /queries/ecma
parentfeat!: bump required Nvim version to 0.9.1 (diff)
downloadnvim-treesitter-78b54eb7f6a9956d25a3911fa0dfd0cabfe2a4c5.tar
nvim-treesitter-78b54eb7f6a9956d25a3911fa0dfd0cabfe2a4c5.tar.gz
nvim-treesitter-78b54eb7f6a9956d25a3911fa0dfd0cabfe2a4c5.tar.bz2
nvim-treesitter-78b54eb7f6a9956d25a3911fa0dfd0cabfe2a4c5.tar.lz
nvim-treesitter-78b54eb7f6a9956d25a3911fa0dfd0cabfe2a4c5.tar.xz
nvim-treesitter-78b54eb7f6a9956d25a3911fa0dfd0cabfe2a4c5.tar.zst
nvim-treesitter-78b54eb7f6a9956d25a3911fa0dfd0cabfe2a4c5.zip
chore(injections)!: update injection syntax to 0.9
Since 0.9, @lang syntax is still available as fallback but will soon be deprecated. Because of that, new syntax should be adopted once 0.9 becomes the baseline requirements for nvim-treesitter - update health check - update doc
Diffstat (limited to 'queries/ecma')
-rw-r--r--queries/ecma/injections.scm92
1 files changed, 52 insertions, 40 deletions
diff --git a/queries/ecma/injections.scm b/queries/ecma/injections.scm
index ba0ea4fa1..3b55295ce 100644
--- a/queries/ecma/injections.scm
+++ b/queries/ecma/injections.scm
@@ -1,59 +1,67 @@
(((comment) @_jsdoc_comment
- (#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @jsdoc)
+ (#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @injection.content
+ (#set! injection.language "jsdoc"))
-(comment) @comment
+((comment) @injection.content
+ (#set! injection.language "comment"))
; html(`...`), html`...`, sql(...) etc
(call_expression
- function: ((identifier) @language)
+ function: ((identifier) @injection.language)
arguments: [
(arguments
- (template_string) @content)
- (template_string) @content
+ (template_string) @injection.content)
+ (template_string) @injection.content
]
- (#offset! @content 0 1 0 -1)
- (#not-eq? @content "svg"))
+ (#offset! @injection.content 0 1 0 -1)
+ (#not-eq? @injection.language "svg"))
; svg`...` or svg(`...`), which uses the html parser, so is not included in the previous query
(call_expression
function: ((identifier) @_name (#eq? @_name "svg"))
arguments: [
(arguments
- (template_string) @html)
- (template_string) @html
+ (template_string) @injection.content)
+ (template_string) @injection.content
]
- (#offset! @html 0 1 0 -1))
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "html"))
(call_expression
function: ((identifier) @_name
(#eq? @_name "gql"))
- arguments: ((template_string) @graphql
- (#offset! @graphql 0 1 0 -1)))
+ arguments: ((template_string) @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "graphql")))
(call_expression
function: ((identifier) @_name
(#eq? @_name "hbs"))
- arguments: ((template_string) @glimmer
- (#offset! @glimmer 0 1 0 -1)))
+ arguments: ((template_string) @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "glimmer")))
-((glimmer_template) @glimmer)
+((glimmer_template) @injection.content
+ (#set! injection.language "glimmer"))
; styled.div`<css>`
(call_expression
function: (member_expression
object: (identifier) @_name
(#eq? @_name "styled"))
- arguments: ((template_string) @css
- (#offset! @css 0 1 0 -1)))
+ arguments: ((template_string) @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "css")))
; styled(Component)`<css>`
(call_expression
function: (call_expression
function: (identifier) @_name
(#eq? @_name "styled"))
- arguments: ((template_string) @css
- (#offset! @css 0 1 0 -1)))
+ arguments: ((template_string) @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "css")))
; styled.div.attrs({ prop: "foo" })`<css>`
(call_expression
@@ -62,8 +70,9 @@
object: (member_expression
object: (identifier) @_name
(#eq? @_name "styled"))))
- arguments: ((template_string) @css
- (#offset! @css 0 1 0 -1)))
+ arguments: ((template_string) @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "css")))
; styled(Component).attrs({ prop: "foo" })`<css>`
@@ -73,31 +82,34 @@
object: (call_expression
function: (identifier) @_name
(#eq? @_name "styled"))))
- arguments: ((template_string) @css
- (#offset! @css 0 1 0 -1)))
+ arguments: ((template_string) @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "css")))
-(regex_pattern) @regex
+((regex_pattern) @injection.content
+ (#set! injection.language "regex"))
; ((comment) @_gql_comment
; (#eq? @_gql_comment "/* GraphQL */")
-; (template_string) @graphql)
+; (template_string) @injection.content
+; (#set! injection.language "graphql"))
-((template_string) @graphql
- (#lua-match? @graphql "^`#graphql")
- (#offset! @graphql 0 1 0 -1))
+((template_string) @injection.content
+ (#lua-match? @injection.content "^`#graphql")
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "graphql"))
; el.innerHTML = `<html>`
-(assignment_expression
- left: (member_expression
- property: (property_identifier) @_prop
- (#any-of? @_prop "innerHTML" "outerHTML"))
- right: (template_string) @html
- (#offset! @html 0 1 0 -1))
-
; el.innerHTML = '<html>'
(assignment_expression
- left: (member_expression
- property: (property_identifier) @_prop
- (#any-of? @_prop "innerHTML" "outerHTML"))
- right: (string) @html
- (#offset! @html 0 1 0 -1))
+ left:
+ (member_expression
+ property: (property_identifier) @_prop
+ (#any-of? @_prop "outerHTML" "innerHTML"))
+ right:
+ [
+ (template_string)
+ (string)
+ ] @injection.content
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.language "html"))