aboutsummaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2025-04-05 12:22:48 +0200
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commitcbfe8a20c76582b0f2532e94fbd7ea9c80f25455 (patch)
tree71353f2a474dafcb90bf0b9783e9c36d99d9a522 /runtime
parentfix(install): skip tier 4 parsers when installing and updating (diff)
downloadnvim-treesitter-cbfe8a20c76582b0f2532e94fbd7ea9c80f25455.tar
nvim-treesitter-cbfe8a20c76582b0f2532e94fbd7ea9c80f25455.tar.gz
nvim-treesitter-cbfe8a20c76582b0f2532e94fbd7ea9c80f25455.tar.bz2
nvim-treesitter-cbfe8a20c76582b0f2532e94fbd7ea9c80f25455.tar.lz
nvim-treesitter-cbfe8a20c76582b0f2532e94fbd7ea9c80f25455.tar.xz
nvim-treesitter-cbfe8a20c76582b0f2532e94fbd7ea9c80f25455.tar.zst
nvim-treesitter-cbfe8a20c76582b0f2532e94fbd7ea9c80f25455.zip
feat(html): use gsub for mimetype lookup
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queries/html_tags/injections.scm30
1 files changed, 27 insertions, 3 deletions
diff --git a/runtime/queries/html_tags/injections.scm b/runtime/queries/html_tags/injections.scm
index 5b78e37b4..1c8ce012b 100644
--- a/runtime/queries/html_tags/injections.scm
+++ b/runtime/queries/html_tags/injections.scm
@@ -32,16 +32,40 @@
(#not-lua-match? @_no_type_lang "%stype%s*=")
(#set! injection.language "javascript"))
-; <script type="mimetype-or-well-known-script-type">
+; <script type="foo/bar">
(script_element
(start_tag
(attribute
(attribute_name) @_attr
(#eq? @_attr "type")
(quoted_attribute_value
- (attribute_value) @_type)))
+ (attribute_value) @injection.language)))
(raw_text) @injection.content
- (#set-lang-from-mimetype! @_type))
+ (#gsub! @injection.language "(.+)/(.+)" "%2"))
+
+; <script type="importmap">
+((script_element
+ (start_tag
+ (attribute
+ (attribute_name) @_attr
+ (#eq? @_attr "type")
+ (quoted_attribute_value
+ (attribute_value) @_type)))
+ (raw_text) @injection.content)
+ (#eq? @_type "importmap")
+ (#set! injection.language "json"))
+
+; <script type="module">
+((script_element
+ (start_tag
+ (attribute
+ (attribute_name) @_attr
+ (#eq? @_attr "type")
+ (quoted_attribute_value
+ (attribute_value) @_type)))
+ (raw_text) @injection.content)
+ (#eq? @_type "module")
+ (#set! injection.language "javascript"))
; <a style="/* css */">
((attribute