From 19b6079fb69b182bc2a4c0dd4bbbbb409bfe9214 Mon Sep 17 00:00:00 2001 From: huhao Date: Sun, 30 Oct 2022 15:54:46 +0800 Subject: [PATCH 1/3] fix https://github.com/helix-editor/helix/issues/4523 --- languages.toml | 22 ++++++++++ runtime/queries/wit/highlights.scm | 67 ++++++++++++++++++++++++++++++ runtime/queries/wit/indents.scm | 13 ++++++ 3 files changed, 102 insertions(+) create mode 100644 runtime/queries/wit/highlights.scm create mode 100644 runtime/queries/wit/indents.scm diff --git a/languages.toml b/languages.toml index 00e6459dee2d..60bc3c211b0c 100644 --- a/languages.toml +++ b/languages.toml @@ -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] +'(' = ')' +'{' = '}' +'[' = ']' +'"' = '"' +"'" = "'" +"<" = ">" + +[[grammar]] +name = "wit" +source = { git = "https://github.com/hh9527/tree-sitter-wit", rev = "1ba571b9930029b7a9836593d4ab29a2ea3f7717" } + diff --git a/runtime/queries/wit/highlights.scm b/runtime/queries/wit/highlights.scm new file mode 100644 index 000000000000..45754a5a8df2 --- /dev/null +++ b/runtime/queries/wit/highlights.scm @@ -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 diff --git a/runtime/queries/wit/indents.scm b/runtime/queries/wit/indents.scm new file mode 100644 index 000000000000..db6c148bf52f --- /dev/null +++ b/runtime/queries/wit/indents.scm @@ -0,0 +1,13 @@ +[ + (use_items) + (fields) + (variant_items) + (variant_payload) + (flags) + (enum_items) + (union_items) + (args) + (resource_items) +] @indent + +[ "}" ")" ] @outdent From 82224539941dda9eb61a3c910adfa44ac9160d22 Mon Sep 17 00:00:00 2001 From: huhao Date: Sun, 30 Oct 2022 23:10:31 +0800 Subject: [PATCH 2/3] update lang-support.md --- book/src/generated/lang-support.md | 1 + 1 file changed, 1 insertion(+) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 545ec635b4b9..38d121b5ac64 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -126,6 +126,7 @@ | wast | ✓ | | | | | wat | ✓ | | | | | wgsl | ✓ | | | `wgsl_analyzer` | +| wit | ✓ | | ✓ | | | xit | ✓ | | | | | xml | ✓ | | ✓ | | | yaml | ✓ | | ✓ | `yaml-language-server` | From cde5bf5753090af1f72719278819a2a8d41985d8 Mon Sep 17 00:00:00 2001 From: hh9527 Date: Mon, 31 Oct 2022 08:38:00 +0800 Subject: [PATCH 3/3] Update languages.toml bump new rev with LICENSE included --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 60bc3c211b0c..33a70e8300f3 100644 --- a/languages.toml +++ b/languages.toml @@ -1937,5 +1937,5 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "wit" -source = { git = "https://github.com/hh9527/tree-sitter-wit", rev = "1ba571b9930029b7a9836593d4ab29a2ea3f7717" } +source = { git = "https://github.com/hh9527/tree-sitter-wit", rev = "c917790ab9aec50c5fd664cbfad8dd45110cfff3" }