mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-12 00:10:04 -04:00
refactor: make html-like languages inherit from single query
This commit is contained in:
parent
801adf2377
commit
5d2faa0466
7 changed files with 61 additions and 119 deletions
|
|
@ -1,43 +1,5 @@
|
||||||
(tag_name) @tag
|
; inherits: html_tags
|
||||||
(erroneous_end_tag_name) @error
|
|
||||||
(doctype) @constant
|
(doctype) @constant
|
||||||
(attribute_name) @property
|
|
||||||
(attribute_value) @string
|
|
||||||
(quoted_attribute_value) @string
|
|
||||||
(comment) @comment
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.title)
|
"<!" @tag.delimiter
|
||||||
(#match? @_tag "^(h[0-9]|title)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.strong)
|
|
||||||
(#match? @_tag "^(strong|b)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
|
|
||||||
(#match? @_tag "^(em|i)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.strike)
|
|
||||||
(#match? @_tag "^(s|del)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.underline)
|
|
||||||
(#eq? @_tag "u"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.literal)
|
|
||||||
(#match? @_tag "^(code|kbd)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.uri)
|
|
||||||
(#eq? @_tag "a"))
|
|
||||||
|
|
||||||
((attribute
|
|
||||||
(attribute_name) @_attr
|
|
||||||
(quoted_attribute_value (attribute_value) @text.uri))
|
|
||||||
(#match? @_attr "^(href|src)$"))
|
|
||||||
|
|
||||||
"=" @operator
|
|
||||||
|
|
||||||
[
|
|
||||||
"<"
|
|
||||||
"<!"
|
|
||||||
">"
|
|
||||||
"</"
|
|
||||||
"/>"
|
|
||||||
] @tag.delimiter
|
|
||||||
|
|
|
||||||
42
queries/html_tags/highlights.scm
Normal file
42
queries/html_tags/highlights.scm
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
(tag_name) @tag
|
||||||
|
(erroneous_end_tag_name) @error
|
||||||
|
(comment) @comment
|
||||||
|
(attribute_name) @property
|
||||||
|
(attribute_value) @string
|
||||||
|
(quoted_attribute_value) @string
|
||||||
|
(text) @none
|
||||||
|
|
||||||
|
((element (start_tag (tag_name) @_tag) (text) @text.title)
|
||||||
|
(#match? @_tag "^(h[0-9]|title)$"))
|
||||||
|
|
||||||
|
((element (start_tag (tag_name) @_tag) (text) @text.strong)
|
||||||
|
(#match? @_tag "^(strong|b)$"))
|
||||||
|
|
||||||
|
((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
|
||||||
|
(#match? @_tag "^(em|i)$"))
|
||||||
|
|
||||||
|
((element (start_tag (tag_name) @_tag) (text) @text.strike)
|
||||||
|
(#match? @_tag "^(s|del)$"))
|
||||||
|
|
||||||
|
((element (start_tag (tag_name) @_tag) (text) @text.underline)
|
||||||
|
(#eq? @_tag "u"))
|
||||||
|
|
||||||
|
((element (start_tag (tag_name) @_tag) (text) @text.literal)
|
||||||
|
(#match? @_tag "^(code|kbd)$"))
|
||||||
|
|
||||||
|
((element (start_tag (tag_name) @_tag) (text) @text.uri)
|
||||||
|
(#eq? @_tag "a"))
|
||||||
|
|
||||||
|
((attribute
|
||||||
|
(attribute_name) @_attr
|
||||||
|
(quoted_attribute_value (attribute_value) @text.uri))
|
||||||
|
(#match? @_attr "^(href|src)$"))
|
||||||
|
|
||||||
|
[
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
"</"
|
||||||
|
"/>"
|
||||||
|
] @tag.delimiter
|
||||||
|
|
||||||
|
"=" @operator
|
||||||
7
queries/html_tags/injections.scm
Normal file
7
queries/html_tags/injections.scm
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
((style_element
|
||||||
|
(raw_text) @css))
|
||||||
|
|
||||||
|
((script_element
|
||||||
|
(raw_text) @javascript))
|
||||||
|
|
||||||
|
(comment) @comment @combined
|
||||||
|
|
@ -1,43 +1,6 @@
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.title)
|
; inherits: html_tags
|
||||||
(#match? @_tag "^(h[0-9]|title)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.strong)
|
(raw_text_expr) @none
|
||||||
(#match? @_tag "^(strong|b)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
|
|
||||||
(#match? @_tag "^(em|i)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.strike)
|
|
||||||
(#match? @_tag "^(s|del)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.underline)
|
|
||||||
(#eq? @_tag "u"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.literal)
|
|
||||||
(#match? @_tag "^(code|kbd)$"))
|
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.uri)
|
|
||||||
(#eq? @_tag "a"))
|
|
||||||
|
|
||||||
((attribute
|
|
||||||
(attribute_name) @_attr
|
|
||||||
(quoted_attribute_value (attribute_value) @text.uri))
|
|
||||||
(#match? @_attr "^(href|src)$"))
|
|
||||||
|
|
||||||
(tag_name) @tag
|
|
||||||
(attribute_name) @property
|
|
||||||
(erroneous_end_tag_name) @error
|
|
||||||
(comment) @comment
|
|
||||||
|
|
||||||
[
|
|
||||||
(attribute_value)
|
|
||||||
(quoted_attribute_value)
|
|
||||||
] @string
|
|
||||||
|
|
||||||
[
|
|
||||||
(text)
|
|
||||||
(raw_text_expr)
|
|
||||||
] @none
|
|
||||||
|
|
||||||
[
|
[
|
||||||
(special_block_keyword)
|
(special_block_keyword)
|
||||||
|
|
@ -50,13 +13,7 @@
|
||||||
"}"
|
"}"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
"=" @operator
|
|
||||||
|
|
||||||
[
|
[
|
||||||
"<"
|
|
||||||
">"
|
|
||||||
"</"
|
|
||||||
"/>"
|
|
||||||
"#"
|
"#"
|
||||||
":"
|
":"
|
||||||
"/"
|
"/"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
((style_element
|
; inherits: html_tags
|
||||||
(raw_text) @css))
|
|
||||||
|
|
||||||
(
|
(
|
||||||
(style_element
|
(style_element
|
||||||
|
|
@ -15,10 +14,7 @@
|
||||||
(quoted_attribute_value (attribute_value) @css))
|
(quoted_attribute_value (attribute_value) @css))
|
||||||
(#eq? @_attr "style"))
|
(#eq? @_attr "style"))
|
||||||
|
|
||||||
((script_element
|
(raw_text_expr) @javascript
|
||||||
(raw_text) @javascript))
|
|
||||||
|
|
||||||
((raw_text_expr) @javascript)
|
|
||||||
|
|
||||||
(
|
(
|
||||||
(script_element
|
(script_element
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,13 @@
|
||||||
|
; inherits: html_tags
|
||||||
|
|
||||||
[
|
[
|
||||||
(component)
|
|
||||||
(template_element)
|
(template_element)
|
||||||
(start_tag)
|
|
||||||
(tag_name)
|
|
||||||
(directive_attribute)
|
(directive_attribute)
|
||||||
(directive_dynamic_argument)
|
(directive_dynamic_argument)
|
||||||
(directive_dynamic_argument_value)
|
(directive_dynamic_argument_value)
|
||||||
(component)
|
(component)
|
||||||
(end_tag)
|
|
||||||
] @tag
|
] @tag
|
||||||
|
|
||||||
(erroneous_end_tag_name) @error
|
|
||||||
(attribute_name) @property
|
|
||||||
(attribute_value) @string
|
|
||||||
(quoted_attribute_value) @string
|
|
||||||
(comment) @comment
|
|
||||||
|
|
||||||
(text) @none
|
|
||||||
(element) @string
|
(element) @string
|
||||||
(interpolation) @punctuation.special
|
(interpolation) @punctuation.special
|
||||||
(interpolation
|
(interpolation
|
||||||
|
|
@ -27,12 +18,3 @@
|
||||||
(directive_name)
|
(directive_name)
|
||||||
(directive_argument)
|
(directive_argument)
|
||||||
] @method
|
] @method
|
||||||
|
|
||||||
"=" @operator
|
|
||||||
|
|
||||||
[
|
|
||||||
"<"
|
|
||||||
">"
|
|
||||||
"</"
|
|
||||||
"/>"
|
|
||||||
] @tag.delimiter
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
((style_element
|
; inherits: html_tags
|
||||||
(raw_text) @css))
|
|
||||||
|
|
||||||
(
|
(
|
||||||
(style_element
|
(style_element
|
||||||
|
|
@ -10,9 +9,6 @@
|
||||||
(#match? @_lang "(scss|postcss|less)")
|
(#match? @_lang "(scss|postcss|less)")
|
||||||
)
|
)
|
||||||
|
|
||||||
((script_element
|
|
||||||
(raw_text) @javascript))
|
|
||||||
|
|
||||||
(
|
(
|
||||||
(script_element
|
(script_element
|
||||||
(start_tag
|
(start_tag
|
||||||
|
|
@ -25,8 +21,8 @@
|
||||||
((interpolation
|
((interpolation
|
||||||
(raw_text) @javascript))
|
(raw_text) @javascript))
|
||||||
|
|
||||||
((directive_attribute
|
((directive_attribute
|
||||||
(quoted_attribute_value
|
(quoted_attribute_value
|
||||||
(attribute_value) @javascript)))
|
(attribute_value) @javascript)))
|
||||||
|
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue