From 17b31a634dfea7ddabe08d39829168a8c2f4c88e Mon Sep 17 00:00:00 2001 From: Jummit Date: Tue, 18 Jul 2023 23:18:29 +0200 Subject: [PATCH] Add wren support --- languages.toml | 13 +++++ runtime/queries/wren/highlights.scm | 81 ++++++++++++++++++++++++++++ runtime/queries/wren/textobjects.scm | 12 +++++ 3 files changed, 106 insertions(+) create mode 100644 runtime/queries/wren/highlights.scm create mode 100644 runtime/queries/wren/textobjects.scm diff --git a/languages.toml b/languages.toml index 7f77429635ccf..df41b838a7f73 100644 --- a/languages.toml +++ b/languages.toml @@ -2698,3 +2698,16 @@ file-types = ["webc"] roots = [] indent = { tab-width = 2, unit = " " } grammar = "html" + +[[grammar]] +name = "wren" +source = { git = "https://git.sr.ht/~jummit/tree-sitter-wren", rev = "7f576e8ccadac226f6a37cbefe95be3fee9f0a66"} + +[[language]] +name = "wren" +scope = "source.wren" +injection-regex = "wren" +file-types = ["wren"] +roots = [] +indent = { tab-width = 2, unit = " "} +grammar = "wren" diff --git a/runtime/queries/wren/highlights.scm b/runtime/queries/wren/highlights.scm new file mode 100644 index 0000000000000..63ecfc26192c1 --- /dev/null +++ b/runtime/queries/wren/highlights.scm @@ -0,0 +1,81 @@ +((identifier) @variable.builtin + (#match? @variable.builtin "^(Bool|Class|Fiber|Fn|List|Map|Null|Num|Object|Range|Sequence|String|System)$")) + +(call_expression + (identifier) @function) + +(method_definition + (identifier) @function.method) + +((parameter) @variable.parameter) + +(comment) @comment +(string) @string +(raw_string) @string +(number) @constant.numeric.integer +(identifier) @variable +(ERROR) @error +(null) @constant.builtin +(boolean) @constant.builtin.boolean + +(if_statement +[ + "if" + "else" +] @keyword.control.conditional) + +(for_statement +[ + "for" + "in" +] @keyword.control.repeat) + +(while_statement +[ + "while" +] @keyword.control.repeat) + +[ + (break_statement) + (continue_statement) + (return_statement) +] @keyword.control.return + +(class_definition +"is" +@keyword) + +[ + "import" + "for" + "as" +] @keyword.control.import + +[ + "is" +] @keyword + +(operator) @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +["," "."] @punctuation.delimiter + +[ + "class" + "var" +] @keyword.storage.type + +[ + "static" +] @keyword.storage.modifier + +(constructor + ["construct"] @constructor) diff --git a/runtime/queries/wren/textobjects.scm b/runtime/queries/wren/textobjects.scm new file mode 100644 index 0000000000000..248981240fba4 --- /dev/null +++ b/runtime/queries/wren/textobjects.scm @@ -0,0 +1,12 @@ +(class_definition + (class_body) @class.inside) @class.around + +(method_definition + body: (_) @function.inside) @function.around + +(parameter_list + ((_) @parameter.inside . ","? @parameter.around) @parameter.around) + +(comment) @comment.inside + +(comment)+ @comment.around