mirror of
https://github.com/laosb/SvelteNova.git
synced 2025-07-08 12:15:34 +00:00
Basic (not working) tree-sitter
syntax highlighting.
This commit is contained in:
parent
1bf00890cd
commit
7c813791aa
9 changed files with 246 additions and 38 deletions
74
SvelteNova.novaextension/Queries/highlights.scm
Normal file
74
SvelteNova.novaextension/Queries/highlights.scm
Normal file
|
@ -0,0 +1,74 @@
|
|||
; This query file is adopted from https://github.com/Himujjal/tree-sitter-svelte/blob/master/queries/highlights.scm.
|
||||
; Nova's highlight captures are different from the original one.
|
||||
|
||||
; ((element (start_tag (tag_name) @_tag) (text) @text.title)
|
||||
; (#match? @_tag "^(h[0-9]|title)$"))
|
||||
;
|
||||
; ((element (start_tag (tag_name) @_tag) (text) @text.strong)
|
||||
; (#match? @_tag "^(strong|b)$"))
|
||||
;
|
||||
; ((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
|
||||
; (#match? @_tag "^(em|i)$"))
|
||||
;
|
||||
; ((element (start_tag (tag_name) @_tag) (text) @text.strike)
|
||||
; (#match? @_tag "^(s|del)$"))
|
||||
;
|
||||
; ((element (start_tag (tag_name) @_tag) (text) @text.underline)
|
||||
; (#eq? @_tag "u"))
|
||||
;
|
||||
; ((element (start_tag (tag_name) @_tag) (text) @text.literal)
|
||||
; (#match? @_tag "^(code|kbd)$"))
|
||||
;
|
||||
; ((element (start_tag (tag_name) @_tag) (text) @text.uri)
|
||||
; (#eq? @_tag "a"))
|
||||
|
||||
((attribute
|
||||
(attribute_name) @_attr
|
||||
(quoted_attribute_value (attribute_value) @tag.attribute.value.link))
|
||||
(#match? @_attr "^(href|src)$"))
|
||||
|
||||
((attribute
|
||||
(attribute_name) @tag.attribute.name
|
||||
["="]? @tag.attribute.operator
|
||||
[
|
||||
(attribute_value) @tag.attribute.value
|
||||
(quoted_attribute_value
|
||||
["\"" "'"] @tag.attribute.value.delimiter.left
|
||||
(_)? @tag.attribute.value
|
||||
["\"" "'"] @tag.attribute.value.delimiter.right
|
||||
)
|
||||
]?
|
||||
)
|
||||
(#not-match? @tag.attribute.name "(?i)^(src|href)$")
|
||||
)
|
||||
|
||||
(tag_name) @tag.name
|
||||
(erroneous_end_tag_name) @invalid
|
||||
(comment) @comment
|
||||
|
||||
(if_start_expr (special_block_keyword) @keyword.condition)
|
||||
(else_expr (special_block_keyword) @keyword.condition)
|
||||
(else_if_expr (special_block_keyword) @keyword.condition)
|
||||
(if_end_expr (special_block_keyword) @keyword.condition)
|
||||
|
||||
[
|
||||
(special_block_keyword)
|
||||
(then)
|
||||
(as)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
("{" "#")
|
||||
("{" ":")
|
||||
("{" "/")
|
||||
("{" "@")
|
||||
] @tag.framework.bracket
|
||||
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
"</"
|
||||
"/>"
|
||||
] @tag.bracket
|
|
@ -9,11 +9,15 @@
|
|||
<preferred-file-extension>svelte</preferred-file-extension>
|
||||
<parent>html</parent>
|
||||
</meta>
|
||||
|
||||
|
||||
<tree-sitter>
|
||||
<highlights />
|
||||
</tree-sitter>
|
||||
|
||||
<detectors>
|
||||
<extension priority="1">svelte</extension>
|
||||
</detectors>
|
||||
|
||||
|
||||
<indentation>
|
||||
<increase>
|
||||
<expression>(?x)
|
||||
|
@ -30,7 +34,7 @@
|
|||
)</expression>
|
||||
</decrease>
|
||||
</indentation>
|
||||
|
||||
|
||||
<comments>
|
||||
<multiline>
|
||||
<starts-with>
|
||||
|
@ -41,7 +45,7 @@
|
|||
</ends-with>
|
||||
</multiline>
|
||||
</comments>
|
||||
|
||||
|
||||
<surrounding-pairs>
|
||||
<pair open="{" close="}" />
|
||||
<pair open="[" close="]" />
|
||||
|
@ -50,7 +54,7 @@
|
|||
<pair open=""" close=""" />
|
||||
<pair open="`" close="`" />
|
||||
</surrounding-pairs>
|
||||
|
||||
|
||||
<scopes spell-check="true" lookup="dictionary">
|
||||
<!-- Meta -->
|
||||
<scope name="html.meta.declaration" spell-check="false" lookup="documentation">
|
||||
|
@ -70,7 +74,7 @@
|
|||
</ends-with>
|
||||
<subscopes />
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Comments -->
|
||||
<scope name="html.comment.block">
|
||||
<starts-with>
|
||||
|
@ -80,10 +84,10 @@
|
|||
<expression>--></expression>
|
||||
</ends-with>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Tags -->
|
||||
<include syntax="self" collection="tags" />
|
||||
|
||||
|
||||
<!-- Values -->
|
||||
<scope name="html.value.entity.numeric" spell-check="false" lookup="documentation">
|
||||
<expression>&\#[0-9]+;</expression>
|
||||
|
@ -346,7 +350,7 @@
|
|||
</strings>
|
||||
</scope>
|
||||
</scopes>
|
||||
|
||||
|
||||
<collections>
|
||||
<!-- Tags -->
|
||||
<collection name="tags">
|
||||
|
@ -393,7 +397,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Javascript -->
|
||||
<scope name="html.embedded.block.script" spell-check="false" lookup="documentation">
|
||||
<starts-with>
|
||||
|
@ -437,7 +441,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- SASS -->
|
||||
<scope name="html.embedded.block.style" spell-check="false" lookup="documentation">
|
||||
<starts-with>
|
||||
|
@ -477,7 +481,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- SCSS -->
|
||||
<scope name="html.embedded.block.style" spell-check="false" lookup="documentation">
|
||||
<starts-with>
|
||||
|
@ -517,7 +521,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- LESS -->
|
||||
<scope name="html.embedded.block.style" spell-check="false" lookup="documentation">
|
||||
<starts-with>
|
||||
|
@ -557,7 +561,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- CSS -->
|
||||
<scope name="html.embedded.block.style" spell-check="false" lookup="documentation">
|
||||
<starts-with>
|
||||
|
@ -597,7 +601,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Closing Tags -->
|
||||
<scope name="html.tag.close" spell-check="false" lookup="documentation">
|
||||
<symbol type="tag">
|
||||
|
@ -606,7 +610,7 @@
|
|||
<expression></([a-zA-Z_][a-zA-Z0-9_:-]*)></expression>
|
||||
<capture number="1" name="html.tag.name" />
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Headings -->
|
||||
<scope name="html.tag.open.paired" spell-check="false" lookup="documentation">
|
||||
<symbol type="tag-heading">
|
||||
|
@ -639,7 +643,7 @@
|
|||
<include syntax="self" collection="attributes" />
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Sections -->
|
||||
<scope name="html.tag.open.paired" spell-check="false" lookup="documentation">
|
||||
<symbol type="tag-section">
|
||||
|
@ -669,7 +673,7 @@
|
|||
<include syntax="self" collection="attributes" />
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Lists -->
|
||||
<scope name="html.tag.open.paired" spell-check="false" lookup="documentation">
|
||||
<symbol type="tag-ul">
|
||||
|
@ -767,7 +771,7 @@
|
|||
<include syntax="self" collection="attributes" />
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Anchors -->
|
||||
<scope name="html.tag.open.paired" spell-check="false" lookup="documentation">
|
||||
<symbol type="tag-anchor">
|
||||
|
@ -794,7 +798,7 @@
|
|||
<include syntax="self" collection="attributes" />
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Elements that are singular tags that should not capture other tags -->
|
||||
<scope name="html.tag.open.single" spell-check="false" lookup="documentation">
|
||||
<symbol type="tag-link">
|
||||
|
@ -873,7 +877,7 @@
|
|||
<include syntax="self" collection="attributes" />
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- All other void elements (self-closing tags) -->
|
||||
<scope name="html.tag.open.single" spell-check="false" lookup="documentation">
|
||||
<symbol type="tag">
|
||||
|
@ -903,7 +907,7 @@
|
|||
<include syntax="self" collection="attributes" />
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- All other tags -->
|
||||
<scope name="html.tag.open.paired" spell-check="false" lookup="documentation">
|
||||
<symbol type="tag">
|
||||
|
@ -928,7 +932,7 @@
|
|||
</subscopes>
|
||||
</scope>
|
||||
</collection>
|
||||
|
||||
|
||||
<!-- Tag Attributes -->
|
||||
<collection name="attributes">
|
||||
<!-- ID attribute -->
|
||||
|
@ -986,7 +990,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Class attribute -->
|
||||
<scope name="html.tag.attribute.class.double-quoted">
|
||||
<starts-with>
|
||||
|
@ -1042,7 +1046,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- ARIA attributes -->
|
||||
<scope name="html.tag.attribute.aria-id.double-quoted">
|
||||
<starts-with>
|
||||
|
@ -1074,7 +1078,7 @@
|
|||
<include syntax="self" collection="attribute-values-single-quoted" />
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Style attributes -->
|
||||
<scope name="html.tag.attribute.style.double-quoted">
|
||||
<starts-with>
|
||||
|
@ -1110,7 +1114,7 @@
|
|||
</cut-off>
|
||||
</subsyntax>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Media attributes -->
|
||||
<scope name="html.tag.attribute.media">
|
||||
<starts-with>
|
||||
|
@ -1127,7 +1131,7 @@
|
|||
<include syntax="css" collection="media-types" />
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Meta attributes -->
|
||||
<scope name="html.tag.attribute.http-equiv.double-quoted">
|
||||
<starts-with>
|
||||
|
@ -1237,7 +1241,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Link attributes -->
|
||||
<scope name="html.tag.attribute.href.double-quoted">
|
||||
<starts-with>
|
||||
|
@ -1347,7 +1351,7 @@
|
|||
</scope>
|
||||
</subscopes>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Script attributes -->
|
||||
<scope name="html.tag.attribute.event-handler">
|
||||
<starts-with>
|
||||
|
@ -1369,7 +1373,7 @@
|
|||
<string>onstorage</string>
|
||||
<string>onundo</string>
|
||||
<string>onunload</string>
|
||||
|
||||
|
||||
<string>onblur</string>
|
||||
<string>onchange</string>
|
||||
<string>oncontextmenu</string>
|
||||
|
@ -1380,11 +1384,11 @@
|
|||
<string>onreset</string>
|
||||
<string>onselect</string>
|
||||
<string>onsubmit</string>
|
||||
|
||||
|
||||
<string>onkeydown</string>
|
||||
<string>onkeypress</string>
|
||||
<string>onkeyup</string>
|
||||
|
||||
|
||||
<string>onclick</string>
|
||||
<string>ondblclick</string>
|
||||
<string>ondrag</string>
|
||||
|
@ -1401,7 +1405,7 @@
|
|||
<string>onmouseup</string>
|
||||
<string>onmousewheel</string>
|
||||
<string>onscroll</string>
|
||||
|
||||
|
||||
<string>onabort</string>
|
||||
<string>oncanplay</string>
|
||||
<string>oncanplaythrough</string>
|
||||
|
@ -1440,7 +1444,7 @@
|
|||
</cut-off>
|
||||
</subsyntax>
|
||||
</scope>
|
||||
|
||||
|
||||
<!-- Generic attributes -->
|
||||
<scope name="html.tag.attribute.double-quoted">
|
||||
<starts-with>
|
||||
|
@ -1490,7 +1494,7 @@
|
|||
<capture number="1" name="html.tag.attribute.name" />
|
||||
</scope>
|
||||
</collection>
|
||||
|
||||
|
||||
<!-- Attribute values -->
|
||||
<collection name="attribute-values-double-quoted">
|
||||
<scope name="html.tag.attribute.value.double-quoted">
|
||||
|
@ -1507,7 +1511,7 @@
|
|||
</subscopes>
|
||||
</scope>
|
||||
</collection>
|
||||
|
||||
|
||||
<collection name="attribute-values-single-quoted">
|
||||
<scope name="html.tag.attribute.value.double-quoted">
|
||||
<starts-with>
|
||||
|
@ -1523,7 +1527,7 @@
|
|||
</subscopes>
|
||||
</scope>
|
||||
</collection>
|
||||
|
||||
|
||||
<collection name="attribute-values-unquoted">
|
||||
<scope name="html.tag.attribute.value">
|
||||
<expression>[a-zA-Z0-9-_]+</expression>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue