Skip to content

Commit

Permalink
Improve vue highlighting
Browse files Browse the repository at this point in the history
support <script>

miss brackets

fix tsx jsx inject
  • Loading branch information
d1y committed May 24, 2024
1 parent 3ec9469 commit 486020f
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions extensions/vue/languages/vue/injections.scm
Original file line number Diff line number Diff line change
@@ -1,7 +1,60 @@
(script_element
(raw_text) @content
; <script>
((script_element
(start_tag) @_no_lang
(raw_text) @content)
(#not-match? @_no_lang "lang=")
(#set! "language" "javascript"))

; <script lang="js">
((script_element
(start_tag
(attribute
(attribute_name) @_lang
(quoted_attribute_value
(attribute_value) @_js)))
(raw_text) @content)
(#eq? @_lang "lang")
(#eq? @_js "js")
(#set! "language" "javascript"))

; <script lang="ts">
((script_element
(start_tag
(attribute
(attribute_name) @_lang
(quoted_attribute_value
(attribute_value) @_ts)))
(raw_text) @content)
(#eq? @_lang "lang")
(#eq? @_ts "ts")
(#set! "language" "typescript"))

; <script lang="tsx">
; <script lang="jsx">
; Zed built-in tsx, we mark it as tsx ^:)
(script_element
(start_tag
(attribute
(attribute_name) @_attr
(quoted_attribute_value
(attribute_value) @language)))
(#eq? @_attr "lang")
(#any-of? @language "tsx" "jsx")
(raw_text) @content)


; {{ }}
((interpolation
(raw_text) @content)
(#set! "language" "typescript"))

; v-
(directive_attribute
(quoted_attribute_value
(attribute_value) @content
(#set! "language" "typescript")))

; TODO: support less/sass/scss
(style_element
(raw_text) @content
(#set! "language" "css"))

0 comments on commit 486020f

Please sign in to comment.