Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support WIT grammar #4525

Merged
merged 4 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
| wast | ✓ | | | |
| wat | ✓ | | | |
| wgsl | ✓ | | | `wgsl_analyzer` |
| wit | ✓ | | ✓ | |
| xit | ✓ | | | |
| xml | ✓ | | ✓ | |
| yaml | ✓ | | ✓ | `yaml-language-server` |
Expand Down
22 changes: 22 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1917,3 +1917,25 @@ roots = []
[[grammar]]
name = "xml"
source = { git = "https://github.com/RenjiSann/tree-sitter-xml", rev = "422528a43630db6dcc1e222d1c5ee3babd559473" }

[[language]]
name = "wit"
scope = "source.wit"
injection-regex = "wit"
file-types = ["wit"]
roots = []
comment-token = "//"
indent = { tab-width = 2, unit = " " }

[language.auto-pairs]
'(' = ')'
'{' = '}'
'[' = ']'
'"' = '"'
"'" = "'"
"<" = ">"
hh9527 marked this conversation as resolved.
Show resolved Hide resolved

[[grammar]]
name = "wit"
source = { git = "https://github.com/hh9527/tree-sitter-wit", rev = "c917790ab9aec50c5fd664cbfad8dd45110cfff3" }

67 changes: 67 additions & 0 deletions runtime/queries/wit/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
(line_comment) @comment.line
(block_comment) @comment.block
(ty (ident) @type)

(item_type name: (ident) @type)
(item_record name: (ident) @type)
(item_variant name: (ident) @type)
(item_flags name: (ident) @type)
(item_enum name: (ident) @type)
(item_union name: (ident) @type)
(item_resource name: (ident) @type)

(item_use from: (ident) @namespace)
(use_item name: (ident) @type)
(item_func name: (ident) @function)
(method name: (ident) @function.method)
(fields (named_ty name: (ident) @variable.other.member))
(input (args (named_ty name: (ident) @variable.parameter)))
(output (args (named_ty name: (ident) @variable.other.member)))
(flags (ident) @constant)
(enum_items (ident) @constant)
(variant_item tag: (ident) @type.enum.variant)

[
(unit)

"u8" "u16" "u32" "u64"
"s8" "s16" "s32" "s64"
"float32" "float64"
"char" "bool" "string"
] @type.builtin

[
"list"
"option"
"result"
"tuple"
"future"
"stream"
] @function.macro

[ "," ":" ] @punctuation.delimiter
[ "(" ")" "{" "}" "<" ">" ] @punctuation.bracket
[ "=" "->" ] @operator

[
"record"
"flags"
"variant"
"enum"
"union"
"type"
"resource"
] @keyword.storage.type

"func" @keyword

[
"static"
] @keyword.storage.modifier

[
(star)
"use"
"as"
"from"
] @keyword.control.import
13 changes: 13 additions & 0 deletions runtime/queries/wit/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
(use_items)
(fields)
(variant_items)
(variant_payload)
(flags)
(enum_items)
(union_items)
(args)
(resource_items)
] @indent

[ "}" ")" ] @outdent