diff --git a/lockfile.json b/lockfile.json index 9414955a8..32885b6e9 100644 --- a/lockfile.json +++ b/lockfile.json @@ -353,6 +353,9 @@ "poe_filter": { "revision": "80dc10195e26c72598ed1ab02cdf2d8e4c792e7b" }, + "pony": { + "revision": "9c6a4d98dea80772dbd7967fe556652a220469e5" + }, "prisma": { "revision": "eca2596a355b1a9952b4f80f8f9caed300a272b5" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 7b9c2dd62..2c770dc82 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1070,6 +1070,14 @@ list.poe_filter = { experimental = true, } +list.pony = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-pony", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq", "@mfelsche" }, +} + list.prisma = { install_info = { url = "https://github.com/victorhqc/tree-sitter-prisma", diff --git a/queries/pony/folds.scm b/queries/pony/folds.scm new file mode 100644 index 000000000..1f7ba11b3 --- /dev/null +++ b/queries/pony/folds.scm @@ -0,0 +1,39 @@ +[ + (use_statement) + (actor_definition) + (class_definition) + (primitive_definition) + (interface_definition) + (trait_definition) + (struct_definition) + + (constructor) + (method) + (behavior) + + (parameters) + + (type) + + (if_statement) + (iftype_statement) + (elseif_block) + (elseiftype_block) + (else_block) + (for_statement) + (while_statement) + (try_statement) + (with_statement) + (repeat_statement) + (recover_statement) + (match_statement) + (case_statement) + (parenthesized_expression) + (tuple_expression) + + (array_literal) + (object_literal) + (string) + + (block_comment) +] @fold diff --git a/queries/pony/highlights.scm b/queries/pony/highlights.scm new file mode 100644 index 000000000..1968693f4 --- /dev/null +++ b/queries/pony/highlights.scm @@ -0,0 +1,292 @@ +; Includes + +[ + "use" +] @include + +; Keywords + +[ + "type" + "actor" + "class" + "primitive" + "interface" + "trait" + "struct" + "embed" + "let" + "var" + (compile_intrinsic) + "as" + "consume" + "recover" + "object" + "where" +] @keyword + +[ + "fun" +] @keyword.function + +[ + "be" +] @keyword.coroutine + +[ + "in" + "is" +] @keyword.operator + +[ + "return" +] @keyword.return + +; Qualifiers + +[ + "iso" + "trn" + "ref" + "val" + "box" + "tag" + "#read" + "#send" + "#share" + "#alias" + "#any" +] @type.qualifier + +; Conditionals + +[ + "if" + "ifdef" + "iftype" + "then" + "else" + "elseif" + "match" +] @conditional + +(if_statement "end" @conditional) + +(iftype_statement "end" @conditional) + +(match_statement "end" @conditional) + +; Repeats + +[ + "repeat" + "until" + "while" + "for" + "continue" + "do" + "break" +] @repeat + +(do_block "end" @repeat) + +(repeat_statement "end" @repeat) + +; Exceptions + +[ + "try" + (error) + "compile_error" +] @exception + +(try_statement "end" @exception) + +(recover_statement "end" @exception) + +; Attributes + +(annotation) @attribute + +; Variables + +(identifier) @variable + +(this) @variable.builtin + +; Fields + +(field name: (identifier) @field) + +(member_expression "." (identifier) @field) + +; Constructors + +(constructor "new" @keyword.operator (identifier) @constructor) + +; Methods + +(method (identifier) @method) + +(behavior (identifier) @method) + +(ffi_method (identifier) @method) + +((ffi_method (string) @string.special) + (#set! "priority" 105)) + +(call_expression + callee: + [ + (identifier) @method.call + (ffi_identifier (identifier) @method.call) + (member_expression "." (identifier) @method.call) + ]) + +; Parameters + +(parameter name: (identifier) @parameter) +(lambda_parameter name: (identifier) @parameter) + +; Types + +(type_alias (identifier) @type.definition) + +(base_type name: (identifier) @type) + +(generic_parameter (identifier) @type) + +(lambda_type (identifier)? @method) + +((identifier) @type + (#lua-match? @type "^_*[A-Z][a-zA-Z0-9_]*$")) + +; Operators + +(unary_expression + operator: ["not" "addressof" "digestof"] @keyword.operator) + +(binary_expression + operator: ["and" "or" "xor" "is" "isnt"] @keyword.operator) + +[ + "=" + "?" + "|" + "&" + "-~" + "+" + "-" + "*" + "/" + "%" + "%%" + "<<" + ">>" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "+~" + "-~" + "*~" + "/~" + "%~" + "%%~" + "<<~" + ">>~" + "==~" + "!=~" + ">~" + ">=~" + "<=~" + "<~" + "+?" + "-?" + "*?" + "/?" + "%?" + "%%?" + "<:" +] @operator + +; Literals + +(string) @string + +(source_file (string) @string.documentation) +(actor_definition (string) @string.documentation) +(class_definition (string) @string.documentation) +(primitive_definition (string) @string.documentation) +(interface_definition (string) @string.documentation) +(trait_definition (string) @string.documentation) +(struct_definition (string) @string.documentation) +(type_alias (string) @string.documentation) +(field (string) @string.documentation) + +(constructor + [ + (string) @string.documentation + (block . (string) @string.documentation) + ]) + +(method + [ + (string) @string.documentation + (block . (string) @string.documentation) + ]) + +(behavior + [ + (string) @string.documentation + (block . (string) @string.documentation) + ]) + +(character) @character + +(escape_sequence) @string.escape + +(number) @number + +(float) @float + +(boolean) @boolean + +; Punctuation + +[ "{" "}" ] @punctuation.bracket + +[ "[" "]" ] @punctuation.bracket + +[ "(" ")" ] @punctuation.bracket + +[ + "." + "," + ";" + ":" + "~" + ".>" + "->" + "=>" +] @punctuation.delimiter + +[ + "@" + "!" + "^" + "..." +] @punctuation.special + +; Comments + +[ + (line_comment) + (block_comment) +] @comment @spell + +; Errors + +(ERROR) @error diff --git a/queries/pony/indents.scm b/queries/pony/indents.scm new file mode 100644 index 000000000..c9b3e7a25 --- /dev/null +++ b/queries/pony/indents.scm @@ -0,0 +1,60 @@ +[ + (use_statement) + (actor_definition) + (class_definition) + (primitive_definition) + (interface_definition) + (trait_definition) + (struct_definition) + + (constructor) + (method) + (behavior) + + (parameters) + + (if_block) + (then_block) + (elseif_block) + (else_block) + (iftype_statement) + (elseiftype_block) + (do_block) + (match_statement) + (parenthesized_expression) + (tuple_expression) + + (array_literal) + (object_literal) +] @indent.begin + +(try_statement (block) @indent.begin) + +(repeat_statement (block) @indent.begin) + +(recover_statement (block) @indent.begin) + +(return_statement (block) @indent.begin) + +(continue_statement (block) @indent.begin) + +(break_statement (block) @indent.begin) + +[ + "}" + "]" + ")" +] @indent.end + +[ "{" "}" ] @indent.branch + +[ "[" "]" ] @indent.branch + +[ "(" ")" ] @indent.branch + +[ + (ERROR) + (string) + (line_comment) + (block_comment) +] @indent.auto diff --git a/queries/pony/injections.scm b/queries/pony/injections.scm new file mode 100644 index 000000000..e48ce9af3 --- /dev/null +++ b/queries/pony/injections.scm @@ -0,0 +1,4 @@ +[ + (line_comment) + (block_comment) +] @comment diff --git a/queries/pony/locals.scm b/queries/pony/locals.scm new file mode 100644 index 000000000..b12f2a04c --- /dev/null +++ b/queries/pony/locals.scm @@ -0,0 +1,91 @@ +; Scopes + +[ + (use_statement) + (actor_definition) + (class_definition) + (primitive_definition) + (interface_definition) + (trait_definition) + (struct_definition) + + (constructor) + (method) + (behavior) + + (if_statement) + (iftype_statement) + (elseif_block) + (elseiftype_block) + (else_block) + (for_statement) + (while_statement) + (try_statement) + (with_statement) + (repeat_statement) + (recover_statement) + (match_statement) + (case_statement) + (parenthesized_expression) + (tuple_expression) + + (array_literal) + (object_literal) +] @scope + +; References + +(identifier) @reference + +; Definitions + +(field + name: (identifier) @definition.field) + +(use_statement + (identifier) @definition.import) + +(constructor + (identifier) @definition.method) + +(method + (identifier) @definition.method) + +(behavior + (identifier) @definition.method) + +(actor_definition + (identifier) @definition.type) + +(type_alias + (identifier) @definition.type) + +(class_definition + (identifier) @definition.type) + +(primitive_definition + (identifier) @definition.type) + +(interface_definition + (identifier) @definition.type) + +(trait_definition + (identifier) @definition.type) + +(struct_definition + (identifier) @definition.type) + +(parameter + name: (identifier) @definition.parameter) + +(variable_declaration + (identifier) @definition.var) + +(for_statement + [ + (identifier) @definition.var + (tuple_expression (identifier) @definition.var) + ]) + +(with_elem + (identifier) @definition.var)