Skip to content

Commit

Permalink
svelte: Adjust block keyword highlighting (#19418)
Browse files Browse the repository at this point in the history
This PR adjusts the highlights for `{#each ...}` and `{#if ...}`
expression blocks to use keyword highlighting.

Extracted from #18052.

Release Notes:

- N/A

Co-authored-by: Albert Marashi <[email protected]>
  • Loading branch information
maxdeviant and AlbertMarashi authored Oct 18, 2024
1 parent 35f2f2a commit 5508832
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 5 additions & 4 deletions extensions/svelte/languages/svelte/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
)
)

; Style self-closing component attributes as @tag.property
(self_closing_tag
(
(tag_name) @_tag_name
Expand Down Expand Up @@ -77,19 +78,19 @@
; Treating (if, each, ...) as a keyword inside of blocks
; like {#if ...} or {#each ...}
(block_start_tag
tag: _ @tag.keyword
tag: _ @keyword
)

(block_tag
tag: _ @tag.keyword
tag: _ @keyword
)

(block_end_tag
tag: _ @tag.keyword
tag: _ @keyword
)

(expression_tag
tag: _ @tag.keyword
tag: _ @keyword
)

; Style quoted string attribute values
Expand Down
8 changes: 3 additions & 5 deletions extensions/svelte/languages/svelte/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
(#set! "language" "ts")
)

; Match style tags with a lang attribute
; Match <style lang="language"> as the specified language
(style_element
(start_tag
(attribute
Expand All @@ -69,7 +69,7 @@
(raw_text) @content
)

; Match style tags without a lang attribute
; Match <style> tags without a lang attribute as CSS
(style_element
(start_tag
(attribute
Expand All @@ -81,6 +81,4 @@
(#set! language "css")
)


; Downstream TODO: Style highlighting for `style:background="red"` and `style="background: red"` strings
; Downstream TODO: Style component comments as markdown
; Downstream TODO: Style @component comments as markdown

0 comments on commit 5508832

Please sign in to comment.