From cc257e9bf9a7eee7e68e04d04523a8fae10807cd Mon Sep 17 00:00:00 2001 From: Roberto Vidal Date: Sat, 1 Oct 2022 16:13:52 +0200 Subject: [PATCH] Add support for webassembly text format (#4040) --- book/src/generated/lang-support.md | 2 ++ languages.toml | 22 ++++++++++++++++++++++ runtime/queries/wast/highlights.scm | 21 +++++++++++++++++++++ runtime/queries/wat/highlights.scm | 17 +++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 runtime/queries/wast/highlights.scm create mode 100644 runtime/queries/wat/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 86c26042d..5c64d0977 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -119,6 +119,8 @@ | vala | ✓ | | | `vala-language-server` | | verilog | ✓ | ✓ | | `svlangserver` | | vue | ✓ | | | `vls` | +| wast | ✓ | | | | +| wat | ✓ | | | | | wgsl | ✓ | | | `wgsl_analyzer` | | xit | ✓ | | | | | yaml | ✓ | | ✓ | `yaml-language-server` | diff --git a/languages.toml b/languages.toml index ab204fcce..d7909b6dc 100644 --- a/languages.toml +++ b/languages.toml @@ -1781,3 +1781,25 @@ language-server = { command = "bass", args = ["--lsp"] } [[grammar]] name = "bass" source = { git = "https://github.com/vito/tree-sitter-bass", rev = "501133e260d768ed4e1fd7374912ed5c86d6fd90" } + +[[language]] +name = "wat" +scope = "source.wat" +comment-token = ";;" +file-types = ["wat"] +roots = [] + +[[grammar]] +name = "wat" +source = { git = "https://github.com/wasm-lsp/tree-sitter-wasm", rev = "2ca28a9f9d709847bf7a3de0942a84e912f59088", subpath = "wat" } + +[[language]] +name = "wast" +scope = "source.wast" +comment-token = ";;" +file-types = ["wast"] +roots = [] + +[[grammar]] +name = "wast" +source = { git = "https://github.com/wasm-lsp/tree-sitter-wasm", rev = "2ca28a9f9d709847bf7a3de0942a84e912f59088", subpath = "wast" } diff --git a/runtime/queries/wast/highlights.scm b/runtime/queries/wast/highlights.scm new file mode 100644 index 000000000..ef5b547ec --- /dev/null +++ b/runtime/queries/wast/highlights.scm @@ -0,0 +1,21 @@ +; inherits: wat + +[ + "assert_return" + "assert_trap" + "assert_exhaustion" + "assert_malformed" + "assert_invalid" + "assert_unlinkable" + "assert_trap" + + "invoke" + "get" + + "script" + "input" + "output" + + "binary" + "quote" +] @keyword diff --git a/runtime/queries/wat/highlights.scm b/runtime/queries/wat/highlights.scm new file mode 100644 index 000000000..007e3bbff --- /dev/null +++ b/runtime/queries/wat/highlights.scm @@ -0,0 +1,17 @@ +["module" "func" "param" "result" "type" "memory" "elem" "data" "table" "global"] @keyword + +["import" "export"] @keyword.control.import + +["local"] @keyword.storage.type + +[(name) (string)] @string + +(identifier) @function + +[(comment_block) (comment_line)] @comment + +[(nat) (float) (align_offset_value)] @constant.numeric.integer + +(value_type) @type + +["(" ")"] @punctuation.bracket