on master help sign in
languages: add svelte support (#733)
b2195e0Raphael Megzari
.gitmodules+4
@@ -118,3 +118,7 @@
118 path = helix-syntax/languages/tree-sitter-zig
118 path = helix-syntax/languages/tree-sitter-zig
119 url = https://github.com/maxxnino/tree-sitter-zig
119 url = https://github.com/maxxnino/tree-sitter-zig
120 shallow = true
120 shallow = true
121+[submodule "helix-syntax/languages/tree-sitter-svelte"]
122+ path = helix-syntax/languages/tree-sitter-svelte
123+ url = https://github.com/Himujjal/tree-sitter-svelte
124+ shallow = true
languages.toml+9
@@ -277,6 +277,15 @@ roots = []
277comment-token = "--"
277comment-token = "--"
278indent = { tab-width = 2, unit = " " }
278indent = { tab-width = 2, unit = " " }
279
279
280+[[language]]
281+name = "svelte"
282+scope = "source.svelte"
283+injection-regex = "svelte"
284+file-types = ["svelte"]
285+roots = []
286+indent = { tab-width = 2, unit = " " }
287+language-server = { command = "svelteserver", args = ["--stdio"] }
288+
280[[language]]
289[[language]]
281name = "yaml"
290name = "yaml"
282scope = "source.yaml"
291scope = "source.yaml"
runtime/queries/svelte/highlights.scmnew file+68
@@ -0,0 +1,68 @@
1+; Special identifiers
2+;--------------------
3+
4+; TODO:
5+((element (start_tag (tag_name) @_tag) (text) @markup.heading)
6+ (#match? @_tag "^(h[0-9]|title)$"))
7+
8+((element (start_tag (tag_name) @_tag) (text) @markup.bold)
9+ (#match? @_tag "^(strong|b)$"))
10+
11+((element (start_tag (tag_name) @_tag) (text) @markup.italic)
12+ (#match? @_tag "^(em|i)$"))
13+
14+; ((element (start_tag (tag_name) @_tag) (text) @markup.strike)
15+; (#match? @_tag "^(s|del)$"))
16+
17+((element (start_tag (tag_name) @_tag) (text) @markup.underline)
18+ (#eq? @_tag "u"))
19+
20+((element (start_tag (tag_name) @_tag) (text) @markup.inline)
21+ (#match? @_tag "^(code|kbd)$"))
22+
23+((element (start_tag (tag_name) @_tag) (text) @markup.underline.link)
24+ (#eq? @_tag "a"))
25+
26+((attribute
27+ (attribute_name) @_attr
28+ (quoted_attribute_value (attribute_value) @markup.undeline.link))
29+ (#match? @_attr "^(href|src)$"))
30+
31+(tag_name) @tag
32+(attribute_name) @property
33+(erroneous_end_tag_name) @error
34+(comment) @comment
35+
36+[
37+ (attribute_value)
38+ (quoted_attribute_value)
39+] @string
40+
41+[
42+ (text)
43+ (raw_text_expr)
44+] @none
45+
46+[
47+ (special_block_keyword)
48+ (then)
49+ (as)
50+] @keyword
51+
52+[
53+ "{"
54+ "}"
55+] @punctuation.brackets
56+
57+"=" @operator
58+
59+[
60+ "<"
61+ ">"
62+ "</"
63+ "/>"
64+ "#"
65+ ":"
66+ "/"
67+ "@"
68+] @punctuation.definition.tag
runtime/queries/svelte/indents.tomlnew file+18
@@ -0,0 +1,18 @@
1+indent = [
2+ "element"
3+ "if_statement"
4+ "each_statement"
5+ "await_statement"
6+]
7+
8+outdent = [
9+ "end_tag"
10+ "else_statement"
11+ "if_end_expr"
12+ "each_end_expr"
13+ "await_end_expr"
14+ ">"
15+ "/>"
16+]
17+
18+ignore = "comment"
runtime/queries/svelte/injections.scmnew file+30
@@ -0,0 +1,30 @@
1+; injections.scm
2+; --------------
3+((style_element
4+ (raw_text) @injection.content)
5+ (#set! injection.language "css"))
6+
7+((attribute
8+ (attribute_name) @_attr
9+ (quoted_attribute_value (attribute_value) @css))
10+ (#eq? @_attr "style"))
11+
12+((script_element
13+ (raw_text) @injection.content)
14+ (#set! injection.language "javascript"))
15+
16+((raw_text_expr) @injection.content
17+ (#set! injection.language "javascript"))
18+
19+(
20+ (script_element
21+ (start_tag
22+ (attribute
23+ (quoted_attribute_value (attribute_value) @_lang)))
24+ (raw_text) @injection.content)
25+ (#match? @_lang "(ts|typescript)")
26+ (#set! injection.language "typescript")
27+)
28+
29+(comment) @comment
30+