svelte: Improve syntax highlighting (#12788)
This PR fixes `<script context="module">` not being highlighted. It also adds support for scss. Release Notes: - N/A
This commit is contained in:
parent
15662f105e
commit
d32e9f759c
1 changed files with 56 additions and 17 deletions
|
@ -1,32 +1,71 @@
|
||||||
; injections.scm
|
; injections.scm
|
||||||
; --------------
|
; --------------
|
||||||
|
|
||||||
|
; match script tags without a lang tag
|
||||||
((script_element
|
((script_element
|
||||||
(start_tag
|
(start_tag
|
||||||
(attribute
|
(attribute
|
||||||
(quoted_attribute_value (attribute_value) @_language))?)
|
(attribute_name) @_name)*)
|
||||||
(raw_text) @content)
|
(raw_text) @content)
|
||||||
(#eq? @_language "")
|
(#not-eq? @_name "lang")
|
||||||
(#set! "language" "javascript"))
|
(#set! "language" "javascript"))
|
||||||
|
|
||||||
((script_element
|
; match javascript
|
||||||
(start_tag
|
|
||||||
(attribute
|
|
||||||
(quoted_attribute_value (attribute_value) @_language)))
|
|
||||||
(raw_text) @content)
|
|
||||||
(#eq? @_language "ts")
|
|
||||||
(#set! "language" "typescript"))
|
|
||||||
|
|
||||||
((script_element
|
((script_element
|
||||||
(start_tag
|
(start_tag
|
||||||
(attribute
|
(attribute
|
||||||
(quoted_attribute_value (attribute_value) @_language)))
|
(attribute_name) @_name
|
||||||
|
(quoted_attribute_value (attribute_value) @_value)))
|
||||||
(raw_text) @content)
|
(raw_text) @content)
|
||||||
(#eq? @_language "typescript")
|
(#eq? @_name "lang")
|
||||||
|
(#eq? @_value "js")
|
||||||
|
(#set! "language" "javascript"))
|
||||||
|
|
||||||
|
; match typescript
|
||||||
|
((script_element
|
||||||
|
(start_tag
|
||||||
|
(attribute
|
||||||
|
(attribute_name) @_name
|
||||||
|
(quoted_attribute_value (attribute_value) @_value)))
|
||||||
|
(raw_text) @content)
|
||||||
|
(#eq? @_name "lang")
|
||||||
|
(#eq? @_value "ts")
|
||||||
(#set! "language" "typescript"))
|
(#set! "language" "typescript"))
|
||||||
|
|
||||||
(style_element
|
(style_element
|
||||||
(raw_text) @content
|
(raw_text) @content
|
||||||
(#set! "language" "css"))
|
(#set! "language" "css"))
|
||||||
|
|
||||||
|
; match style tags without a lang tag
|
||||||
|
((style_element
|
||||||
|
(start_tag
|
||||||
|
(attribute
|
||||||
|
(attribute_name) @_name)*)
|
||||||
|
(raw_text) @content)
|
||||||
|
(#not-eq? @_name "lang")
|
||||||
|
(#set! "language" "css"))
|
||||||
|
|
||||||
|
; match css
|
||||||
|
((style_element
|
||||||
|
(start_tag
|
||||||
|
(attribute
|
||||||
|
(attribute_name) @_name
|
||||||
|
(quoted_attribute_value (attribute_value) @_value)))
|
||||||
|
(raw_text) @content)
|
||||||
|
(#eq? @_name "lang")
|
||||||
|
(#eq? @_value "css")
|
||||||
|
(#set! "language" "css"))
|
||||||
|
|
||||||
|
; match scss
|
||||||
|
((style_element
|
||||||
|
(start_tag
|
||||||
|
(attribute
|
||||||
|
(attribute_name) @_name
|
||||||
|
(quoted_attribute_value (attribute_value) @_value)))
|
||||||
|
(raw_text) @content)
|
||||||
|
(#eq? @_name "lang")
|
||||||
|
(#eq? @_value "scss")
|
||||||
|
(#set! "language" "scss"))
|
||||||
|
|
||||||
((raw_text_expr) @content
|
((raw_text_expr) @content
|
||||||
(#set! "language" "javascript"))
|
(#set! "language" "javascript"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue