mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-15 01:40:02 -04:00
Merge f4f9a36fa4 into 539abf6da5
This commit is contained in:
commit
fa015c8f54
2 changed files with 134 additions and 72 deletions
|
|
@ -5,48 +5,78 @@
|
||||||
((comment) @injection.content
|
((comment) @injection.content
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
; html(`...`), html`...`, sql(`...`), etc.
|
; html(`...`), sql(`...`), etc.
|
||||||
(call_expression
|
(call_expression
|
||||||
function: (identifier) @injection.language
|
function: (identifier) @injection.language
|
||||||
arguments: [
|
arguments: (arguments
|
||||||
(arguments
|
(template_string
|
||||||
(template_string) @injection.content)
|
[
|
||||||
(template_string) @injection.content
|
(string_fragment) @injection.content
|
||||||
]
|
(template_substitution)
|
||||||
|
]+))
|
||||||
(#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$")
|
(#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$")
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
|
||||||
(#set! injection.include-children)
|
|
||||||
; Languages excluded from auto-injection due to special rules
|
; Languages excluded from auto-injection due to special rules
|
||||||
; - svg uses the html parser
|
; - svg uses the html parser
|
||||||
; - css uses the styled parser
|
; - css uses the styled parser
|
||||||
(#not-any-of? @injection.language "svg" "css"))
|
(#not-any-of? @injection.language "svg" "css"))
|
||||||
|
|
||||||
; svg`...` or svg(`...`)
|
; html`...`, sql`...`, etc.
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @injection.language
|
||||||
|
arguments: (template_string
|
||||||
|
[
|
||||||
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
|
(#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$")
|
||||||
|
(#not-any-of? @injection.language "svg" "css"))
|
||||||
|
|
||||||
|
; svg(`...`)
|
||||||
(call_expression
|
(call_expression
|
||||||
function: (identifier) @_name
|
function: (identifier) @_name
|
||||||
(#eq? @_name "svg")
|
(#eq? @_name "svg")
|
||||||
arguments: [
|
arguments: (arguments
|
||||||
(arguments
|
(template_string
|
||||||
(template_string) @injection.content)
|
[
|
||||||
(template_string) @injection.content
|
(string_fragment) @injection.content
|
||||||
]
|
(template_substitution)
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
]+))
|
||||||
(#set! injection.include-children)
|
(#set! injection.language "html"))
|
||||||
|
|
||||||
|
; svg`...`
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @_name
|
||||||
|
(#eq? @_name "svg")
|
||||||
|
arguments: (template_string
|
||||||
|
[
|
||||||
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "html"))
|
(#set! injection.language "html"))
|
||||||
|
|
||||||
; Vercel PostgreSQL
|
; Vercel PostgreSQL
|
||||||
; foo.sql`...` or foo.sql(`...`)
|
; foo.sql(`...`)
|
||||||
(call_expression
|
(call_expression
|
||||||
function: (member_expression
|
function: (member_expression
|
||||||
property: (property_identifier) @injection.language)
|
property: (property_identifier) @injection.language)
|
||||||
arguments: [
|
arguments: (arguments
|
||||||
(arguments
|
(template_string
|
||||||
(template_string) @injection.content)
|
[
|
||||||
(template_string) @injection.content
|
(string_fragment) @injection.content
|
||||||
]
|
(template_substitution)
|
||||||
(#eq? @injection.language "sql")
|
]+))
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
(#eq? @injection.language "sql"))
|
||||||
(#set! injection.include-children))
|
|
||||||
|
; foo.sql`...`
|
||||||
|
(call_expression
|
||||||
|
function: (member_expression
|
||||||
|
property: (property_identifier) @injection.language)
|
||||||
|
arguments: (template_string
|
||||||
|
[
|
||||||
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
|
(#eq? @injection.language "sql"))
|
||||||
|
|
||||||
; Sanity CMS GROQ query
|
; Sanity CMS GROQ query
|
||||||
; defineQuery(`...`)
|
; defineQuery(`...`)
|
||||||
|
|
@ -54,39 +84,55 @@
|
||||||
function: (identifier) @_name
|
function: (identifier) @_name
|
||||||
(#eq? @_name "defineQuery")
|
(#eq? @_name "defineQuery")
|
||||||
arguments: (arguments
|
arguments: (arguments
|
||||||
(template_string) @injection.content)
|
(template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+))
|
||||||
(#set! injection.language "groq"))
|
(#set! injection.language "groq"))
|
||||||
|
|
||||||
; gql`...` or gql(`...`)
|
; gql(`...`)
|
||||||
(call_expression
|
(call_expression
|
||||||
function: (identifier) @_name
|
function: (identifier) @_name
|
||||||
(#eq? @_name "gql")
|
(#eq? @_name "gql")
|
||||||
arguments: [
|
arguments: (arguments
|
||||||
(arguments
|
(template_string
|
||||||
(template_string) @injection.content)
|
[
|
||||||
(template_string) @injection.content
|
(string_fragment) @injection.content
|
||||||
]
|
(template_substitution)
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
]+))
|
||||||
(#set! injection.include-children)
|
(#set! injection.language "graphql"))
|
||||||
|
|
||||||
|
; gql`...`
|
||||||
|
(call_expression
|
||||||
|
function: (identifier) @_name
|
||||||
|
(#eq? @_name "gql")
|
||||||
|
arguments: (template_string
|
||||||
|
[
|
||||||
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "graphql"))
|
(#set! injection.language "graphql"))
|
||||||
|
|
||||||
(call_expression
|
(call_expression
|
||||||
function: (identifier) @_name
|
function: (identifier) @_name
|
||||||
(#eq? @_name "hbs")
|
(#eq? @_name "hbs")
|
||||||
arguments: (template_string) @injection.content
|
arguments: (template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "glimmer"))
|
(#set! injection.language "glimmer"))
|
||||||
|
|
||||||
; css`<css>`, keyframes`<css>`
|
; css`<css>`, keyframes`<css>`
|
||||||
(call_expression
|
(call_expression
|
||||||
function: (identifier) @_name
|
function: (identifier) @_name
|
||||||
(#any-of? @_name "css" "keyframes")
|
(#any-of? @_name "css" "keyframes")
|
||||||
arguments: (template_string) @injection.content
|
arguments: (template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "styled"))
|
(#set! injection.language "styled"))
|
||||||
|
|
||||||
; styled.div`<css>`
|
; styled.div`<css>`
|
||||||
|
|
@ -94,9 +140,11 @@
|
||||||
function: (member_expression
|
function: (member_expression
|
||||||
object: (identifier) @_name
|
object: (identifier) @_name
|
||||||
(#eq? @_name "styled"))
|
(#eq? @_name "styled"))
|
||||||
arguments: ((template_string) @injection.content
|
arguments: ((template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "styled")))
|
(#set! injection.language "styled")))
|
||||||
|
|
||||||
; styled(Component)`<css>`
|
; styled(Component)`<css>`
|
||||||
|
|
@ -104,9 +152,11 @@
|
||||||
function: (call_expression
|
function: (call_expression
|
||||||
function: (identifier) @_name
|
function: (identifier) @_name
|
||||||
(#eq? @_name "styled"))
|
(#eq? @_name "styled"))
|
||||||
arguments: ((template_string) @injection.content
|
arguments: ((template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "styled")))
|
(#set! injection.language "styled")))
|
||||||
|
|
||||||
; styled.div.attrs({ prop: "foo" })`<css>`
|
; styled.div.attrs({ prop: "foo" })`<css>`
|
||||||
|
|
@ -116,9 +166,11 @@
|
||||||
object: (member_expression
|
object: (member_expression
|
||||||
object: (identifier) @_name
|
object: (identifier) @_name
|
||||||
(#eq? @_name "styled"))))
|
(#eq? @_name "styled"))))
|
||||||
arguments: ((template_string) @injection.content
|
arguments: ((template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "styled")))
|
(#set! injection.language "styled")))
|
||||||
|
|
||||||
; styled(Component).attrs({ prop: "foo" })`<css>`
|
; styled(Component).attrs({ prop: "foo" })`<css>`
|
||||||
|
|
@ -128,9 +180,11 @@
|
||||||
object: (call_expression
|
object: (call_expression
|
||||||
function: (identifier) @_name
|
function: (identifier) @_name
|
||||||
(#eq? @_name "styled"))))
|
(#eq? @_name "styled"))))
|
||||||
arguments: ((template_string) @injection.content
|
arguments: ((template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "styled")))
|
(#set! injection.language "styled")))
|
||||||
|
|
||||||
((regex_pattern) @injection.content
|
((regex_pattern) @injection.content
|
||||||
|
|
@ -140,10 +194,10 @@
|
||||||
; (#eq? @_gql_comment "/* GraphQL */")
|
; (#eq? @_gql_comment "/* GraphQL */")
|
||||||
; (template_string) @injection.content
|
; (template_string) @injection.content
|
||||||
; (#set! injection.language "graphql"))
|
; (#set! injection.language "graphql"))
|
||||||
((template_string) @injection.content
|
((template_string
|
||||||
(#lua-match? @injection.content "^`#graphql")
|
(string_fragment) @injection.content)
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
(#lua-match? @injection.content "^#graphql")
|
||||||
(#set! injection.include-children)
|
(#set! injection.combined)
|
||||||
(#set! injection.language "graphql"))
|
(#set! injection.language "graphql"))
|
||||||
|
|
||||||
; el.innerHTML = `<html>`
|
; el.innerHTML = `<html>`
|
||||||
|
|
@ -151,9 +205,11 @@
|
||||||
left: (member_expression
|
left: (member_expression
|
||||||
property: (property_identifier) @_prop
|
property: (property_identifier) @_prop
|
||||||
(#any-of? @_prop "outerHTML" "innerHTML"))
|
(#any-of? @_prop "outerHTML" "innerHTML"))
|
||||||
right: (template_string) @injection.content
|
right: (template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "html"))
|
(#set! injection.language "html"))
|
||||||
|
|
||||||
; el.innerHTML = '<html>'
|
; el.innerHTML = '<html>'
|
||||||
|
|
@ -178,9 +234,11 @@
|
||||||
(pair
|
(pair
|
||||||
key: ((property_identifier) @_prop
|
key: ((property_identifier) @_prop
|
||||||
(#eq? @_prop "template"))
|
(#eq? @_prop "template"))
|
||||||
value: ((template_string) @injection.content
|
value: ((template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "angular")))))))
|
(#set! injection.language "angular")))))))
|
||||||
|
|
||||||
; @Component({
|
; @Component({
|
||||||
|
|
@ -196,9 +254,11 @@
|
||||||
key: ((property_identifier) @_prop
|
key: ((property_identifier) @_prop
|
||||||
(#eq? @_prop "styles"))
|
(#eq? @_prop "styles"))
|
||||||
value: (array
|
value: (array
|
||||||
((template_string) @injection.content
|
((template_string
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
[
|
||||||
(#set! injection.include-children)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "css"))))))))
|
(#set! injection.language "css"))))))))
|
||||||
|
|
||||||
; @Component({
|
; @Component({
|
||||||
|
|
@ -213,7 +273,9 @@
|
||||||
(pair
|
(pair
|
||||||
key: ((property_identifier) @_prop
|
key: ((property_identifier) @_prop
|
||||||
(#eq? @_prop "styles"))
|
(#eq? @_prop "styles"))
|
||||||
value: ((template_string) @injection.content
|
value: ((template_string
|
||||||
(#set! injection.include-children)
|
[
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
(string_fragment) @injection.content
|
||||||
|
(template_substitution)
|
||||||
|
]+)
|
||||||
(#set! injection.language "css")))))))
|
(#set! injection.language "css")))))))
|
||||||
|
|
|
||||||
|
|
@ -81,13 +81,13 @@
|
||||||
((attribute
|
((attribute
|
||||||
(quoted_attribute_value
|
(quoted_attribute_value
|
||||||
(attribute_value) @injection.content))
|
(attribute_value) @injection.content))
|
||||||
(#lua-match? @injection.content "%${")
|
(#lua-match? @injection.content "^%${")
|
||||||
(#offset! @injection.content 0 2 0 -1)
|
(#offset! @injection.content 0 2 0 -1)
|
||||||
(#set! injection.language "javascript"))
|
(#set! injection.language "javascript"))
|
||||||
|
|
||||||
((attribute
|
((attribute
|
||||||
(attribute_value) @injection.content)
|
(attribute_value) @injection.content)
|
||||||
(#lua-match? @injection.content "%${")
|
(#lua-match? @injection.content "^%${")
|
||||||
(#offset! @injection.content 0 2 0 -2)
|
(#offset! @injection.content 0 2 0 -2)
|
||||||
(#set! injection.language "javascript"))
|
(#set! injection.language "javascript"))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue