nvim-treesitter/queries/vue/injections.scm

98 lines
2 KiB
Scheme
Raw Normal View History

2022-12-17 12:27:14 +09:00
(
(style_element
(start_tag) @_no_attribute
2022-12-17 12:27:14 +09:00
(raw_text) @css)
2022-12-26 00:38:57 +09:00
(#match? @_no_attribute "^\\<\\s*style\\s*\\>$")
2022-12-26 00:38:57 +09:00
; unsure why, but without escaping &lt; and &gt; the query breaks
2022-12-17 12:27:14 +09:00
)
(
(style_element
(start_tag
(attribute
(attribute_name) @_no_lang))
(raw_text) @css)
(#not-eq? @_no_lang "lang")
)
(
(style_element
(start_tag
(attribute
(attribute_name) @_lang
(quoted_attribute_value (attribute_value) @_css)))
2022-12-17 12:27:14 +09:00
(raw_text) @css)
(#eq? @_lang "lang")
(#eq? @_css "css")
2022-12-17 12:27:14 +09:00
)
; If script tag does not have any extra attributes, set it to javascript
(
(script_element
(start_tag) @_no_attribute
(raw_text) @javascript)
2022-12-26 00:38:57 +09:00
(#match? @_no_attribute "^\\<\\s*script\\s*\\>$")
)
2022-12-17 12:27:14 +09:00
; if start_tag does not specify `lang="..."` then set it to javascript
(
(script_element
(start_tag
(attribute
(attribute_name) @_no_lang))
(raw_text) @javascript)
(#not-eq? @_no_lang "lang")
2022-12-17 12:27:14 +09:00
)
(
(script_element
(start_tag
(attribute
(attribute_name) @_lang
(quoted_attribute_value (attribute_value) @_js)))
2022-12-17 12:27:14 +09:00
(raw_text) @javascript)
(#eq? @_lang "lang")
(#eq? @_js "js")
2022-12-17 12:27:14 +09:00
)
; TODO: When nvim-treesitter have postcss and less parser, use @language and @content instead
(
(style_element
(start_tag
(attribute
(attribute_name) @_lang
(quoted_attribute_value (attribute_value) @_scss)))
(raw_text) @scss)
(#eq? @_lang "lang")
(#any-of? @_scss "scss" "less" "postcss")
)
(
(script_element
(start_tag
(attribute
(attribute_name) @_lang
(quoted_attribute_value (attribute_value) @_ts)))
(raw_text) @typescript)
(#eq? @_lang "lang")
(#eq? @_ts "ts")
)
((interpolation
(raw_text) @javascript))
((directive_attribute
(quoted_attribute_value
2021-04-22 18:52:20 +02:00
(attribute_value) @javascript)))
(
(template_element
(start_tag
(attribute
(quoted_attribute_value (attribute_value) @_lang)))
2021-11-30 23:27:08 +01:00
(text) @pug)
(#eq? @_lang "pug")
)
(comment) @comment