diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md index 153483006..86f2bb7fc 100644 --- a/SUPPORTED_LANGUAGES.md +++ b/SUPPORTED_LANGUAGES.md @@ -322,6 +322,7 @@ jsx (queries only)[^jsx] | unstable | `HFIJ ` | @steelsojka [vimdoc](https://github.com/neovim/tree-sitter-vimdoc) | unstable | `H  J ` | @clason [vrl](https://github.com/belltoy/tree-sitter-vrl) | unstable | `HFIJL` | @belltoy [vue](https://github.com/tree-sitter-grammars/tree-sitter-vue) | unstable | `HFIJ ` | @WhyNotHugo, @lucario387 +[wat](https://github.com/g-plane/tree-sitter-wat) | unstable | `HF   ` | @g-plane [wgsl](https://github.com/szebniok/tree-sitter-wgsl) | unstable | `HFIJ ` | @szebniok [wgsl_bevy](https://github.com/tree-sitter-grammars/tree-sitter-wgsl-bevy) | unstable | `HFI  ` | @theHamsta [wing](https://github.com/winglang/tree-sitter-wing) | unstable | `HF JL` | @gshpychka, @MarkMcCulloh diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index b7037d245..a7dc9916c 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -2560,6 +2560,14 @@ return { requires = { 'html_tags' }, tier = 2, }, + wat = { + install_info = { + revision = '357bbe6053f261b205f5835a87a6ae094226cc57', + url = 'https://github.com/g-plane/tree-sitter-wat', + }, + maintainers = { '@g-plane' }, + tier = 2, + }, wgsl = { install_info = { revision = '40259f3c77ea856841a4e0c4c807705f3e4a2b65', diff --git a/runtime/queries/wat/folds.scm b/runtime/queries/wat/folds.scm new file mode 100644 index 000000000..d6dcac3a7 --- /dev/null +++ b/runtime/queries/wat/folds.scm @@ -0,0 +1,21 @@ +[ + (block_block) + (block_if) + (block_if_else) + (block_if_then) + (block_loop) + (block_try_table) + (module) + (module_field_data) + (module_field_elem) + (module_field_export) + (module_field_func) + (module_field_global) + (module_field_import) + (module_field_memory) + (module_field_start) + (module_field_table) + (module_field_tag) + (rec_type) + (type_def) +] @fold diff --git a/runtime/queries/wat/highlights.scm b/runtime/queries/wat/highlights.scm new file mode 100644 index 000000000..5050c8b02 --- /dev/null +++ b/runtime/queries/wat/highlights.scm @@ -0,0 +1,143 @@ +[ + (block_comment) + (line_comment) +] @comment + +((block_comment)+ @comment.documentation + (#match? @comment.documentation "^;;;\\s+.*")) + +[ + "block" + "data" + "declare" + "elem" + "end" + "export" + "field" + "final" + "global" + "item" + "local" + "memory" + "module" + "null" + "offset" + "pagesize" + "param" + "rec" + "ref" + "result" + "shared" + "start" + "sub" + "table" + "tag" + "try_table" + "unshared" +] @keyword + +"func" @keyword.function + +"import" @keyword.import + +[ + "type" + "struct" + "array" +] @keyword.type + +"mut" @keyword.modifier + +"loop" @keyword.repeat + +[ + "catch" + "catch_ref" + "catch_all" + "catch_all_ref" +] @keyword.exception + +[ + "if" + "then" + "else" +] @keyword.conditional + +[ + (integer) + (uinteger) +] @number + +(float) @number.float + +(instr_name) @operator + +[ + "(" + ")" +] @punctuation.bracket + +(annotation_start) @attribute + +(string) @string + +((annotation_elem) @string + (#match? @string "^\".*\"$")) + +[ + (num_type) + (vec_type) + (packed_type) +] @type.builtin + +((ref_type) @type.builtin + (#match? @type.builtin "^(any|eq|i31|struct|array|null|(null)?func|(null)?exn|(null)?extern)ref$")) + +((heap_type) @type.builtin + (#match? @type.builtin "^(any|eq|i31|struct|array|null|(null)?func|(null)?exn|(null)?extern)$")) + +(identifier) @variable + +(index + (uinteger) @variable) + +(param + (identifier) @variable.parameter) + +(field + (identifier) @variable.member) + +(module + (identifier) @module) + +([ + (block_block) + (block_if) + (block_loop) + (block_try_table) +] + (identifier) @label) + +(module_field_func + (identifier) @function) + +(extern_type_func + (identifier) @function) + +(module_field_start + (index + [ + (identifier) + (uinteger) + ] @function.call)) + +(plain_instr + ((instr_name) @operator + (#match? @operator "^(return_)?call$")) + [ + (identifier) + (integer) + ] @function.call) + +(type_def + (identifier) @type)