Skip to content

Commit 2d0a764

Browse files
hh9527Frederik Vestre
authored and
Frederik Vestre
committed
Support WIT grammar (helix-editor#4525)
1 parent 3a4656a commit 2d0a764

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

book/src/generated/lang-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
| wast || | | |
127127
| wat || | | |
128128
| wgsl || | | `wgsl_analyzer` |
129+
| wit || || |
129130
| xit || | | |
130131
| xml || || |
131132
| yaml || || `yaml-language-server` |

languages.toml

+22
Original file line numberDiff line numberDiff line change
@@ -1917,3 +1917,25 @@ roots = []
19171917
[[grammar]]
19181918
name = "xml"
19191919
source = { git = "https://github.com/RenjiSann/tree-sitter-xml", rev = "422528a43630db6dcc1e222d1c5ee3babd559473" }
1920+
1921+
[[language]]
1922+
name = "wit"
1923+
scope = "source.wit"
1924+
injection-regex = "wit"
1925+
file-types = ["wit"]
1926+
roots = []
1927+
comment-token = "//"
1928+
indent = { tab-width = 2, unit = " " }
1929+
1930+
[language.auto-pairs]
1931+
'(' = ')'
1932+
'{' = '}'
1933+
'[' = ']'
1934+
'"' = '"'
1935+
"'" = "'"
1936+
"<" = ">"
1937+
1938+
[[grammar]]
1939+
name = "wit"
1940+
source = { git = "https://github.com/hh9527/tree-sitter-wit", rev = "c917790ab9aec50c5fd664cbfad8dd45110cfff3" }
1941+

runtime/queries/wit/highlights.scm

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
(line_comment) @comment.line
2+
(block_comment) @comment.block
3+
(ty (ident) @type)
4+
5+
(item_type name: (ident) @type)
6+
(item_record name: (ident) @type)
7+
(item_variant name: (ident) @type)
8+
(item_flags name: (ident) @type)
9+
(item_enum name: (ident) @type)
10+
(item_union name: (ident) @type)
11+
(item_resource name: (ident) @type)
12+
13+
(item_use from: (ident) @namespace)
14+
(use_item name: (ident) @type)
15+
(item_func name: (ident) @function)
16+
(method name: (ident) @function.method)
17+
(fields (named_ty name: (ident) @variable.other.member))
18+
(input (args (named_ty name: (ident) @variable.parameter)))
19+
(output (args (named_ty name: (ident) @variable.other.member)))
20+
(flags (ident) @constant)
21+
(enum_items (ident) @constant)
22+
(variant_item tag: (ident) @type.enum.variant)
23+
24+
[
25+
(unit)
26+
27+
"u8" "u16" "u32" "u64"
28+
"s8" "s16" "s32" "s64"
29+
"float32" "float64"
30+
"char" "bool" "string"
31+
] @type.builtin
32+
33+
[
34+
"list"
35+
"option"
36+
"result"
37+
"tuple"
38+
"future"
39+
"stream"
40+
] @function.macro
41+
42+
[ "," ":" ] @punctuation.delimiter
43+
[ "(" ")" "{" "}" "<" ">" ] @punctuation.bracket
44+
[ "=" "->" ] @operator
45+
46+
[
47+
"record"
48+
"flags"
49+
"variant"
50+
"enum"
51+
"union"
52+
"type"
53+
"resource"
54+
] @keyword.storage.type
55+
56+
"func" @keyword
57+
58+
[
59+
"static"
60+
] @keyword.storage.modifier
61+
62+
[
63+
(star)
64+
"use"
65+
"as"
66+
"from"
67+
] @keyword.control.import

runtime/queries/wit/indents.scm

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
(use_items)
3+
(fields)
4+
(variant_items)
5+
(variant_payload)
6+
(flags)
7+
(enum_items)
8+
(union_items)
9+
(args)
10+
(resource_items)
11+
] @indent
12+
13+
[ "}" ")" ] @outdent

0 commit comments

Comments
 (0)