From 99988f6eb7a6d898767813be6da48c49a2edc792 Mon Sep 17 00:00:00 2001 From: r001 Date: Sun, 22 Oct 2023 03:23:02 +0200 Subject: [PATCH] feat: leo parser and queries (#5542) --- lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 8 ++ queries/leo/highlights.scm | 177 ++++++++++++++++++++++++++++++++ queries/leo/injections.scm | 2 + 4 files changed, 190 insertions(+) create mode 100644 queries/leo/highlights.scm create mode 100644 queries/leo/injections.scm diff --git a/lockfile.json b/lockfile.json index e2706fc6b..22a59021a 100644 --- a/lockfile.json +++ b/lockfile.json @@ -323,6 +323,9 @@ "ledger": { "revision": "8a841fb20ce683bfbb3469e6ba67f2851cfdf94a" }, + "leo": { + "revision": "bf56a34745ee7a322442702f3aef2e633bb0b36c" + }, "liquidsoap": { "revision": "4acf9035d852fc65e013f05f597635204e6d1ca5" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 526a34cd7..47a1593e1 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -984,6 +984,14 @@ list.ledger = { maintainers = { "@cbarrete" }, } +list.leo = { + install_info = { + url = "https://github.com/r001/tree-sitter-leo", + files = { "src/parser.c" }, + }, + maintainers = { "@r001" }, +} + list.llvm = { install_info = { url = "https://github.com/benwilliamgraham/tree-sitter-llvm", diff --git a/queries/leo/highlights.scm b/queries/leo/highlights.scm new file mode 100644 index 000000000..4114f41f9 --- /dev/null +++ b/queries/leo/highlights.scm @@ -0,0 +1,177 @@ +(variable) @variable + +[ + "assert" + "assert_eq" + "assert_neq" + "block" + "console" + "const" + "let" + "mapping" + "program" + "record" + "self" + "struct" +] @keyword + + "in" @keyword.operator + +[ + "constant" + "private" + "public" + ] @type.qualifier + +"self" @variable.builtin + +[ + "finalize" + "function" + "inline" + "transition" +] @keyword.function + +"import" @include + +"return" @keyword.return + +(return_arrow) @punctuation.delimiter + +"for" @repeat + +[ + "else" + "if" + "then" +] @conditional + +[ + (ternary_if) + (ternary_else) +] @conditional.ternary + +[ "(" ")" "{" "}" "[" "]" ] @punctuation.bracket + +[ ";" "," "::"] @punctuation.delimiter + +[ +"!" + +"&&" +"||" + +"==" +"!=" + +"<" +"<=" +">" +">=" + +"&" +"|" +"^" + +"<<" +">>" + +"+" +"-" +"*" +"/" +"%" +"**" + +"=" + +"+=" +"-=" +"*=" +"/=" +"%=" +"**=" + +"<<=" +">>=" + +"&=" +"|=" +"^=" + +"&&=" +"||=" + +] @operator + +(comment) @comment @spell + +(boolean_literal) @boolean + +(constant_declaration + (identifier) @constant) + +[ + (program_id) + (this_program_id) +] @string.special + +;record declaration +(record_declaration (identifier) @field) + +;struct component +(struct_component_declaration + (identifier) @field) + +(type) @type + +(associated_constant) @constant + +[ + (block_height) + (self_caller) +] @constant.builtin + +(free_function_call + (locator + (identifier) @function)) + +(record_type + (locator + (identifier) @field)) + +(transition_declaration + name: (identifier) @function.builtin) + +(free_function_call + (identifier) @function.call) + +(function_declaration + name: (identifier) @function) + +(inline_declaration + name: (identifier) @function.macro) + +(method_call + . (_) + . (identifier) @method.call) + +(function_parameter + (identifier) @parameter) + +(struct_declaration + name: (identifier) @field) + +(variable_declaration + (identifier_or_identifiers + (identifier) @variable)) + +[ + (address_literal) + (affine_group_literal) + (field_literal) + (product_group_literal) + (scalar_literal) + (signed_literal) + (unsigned_literal) +] @number diff --git a/queries/leo/injections.scm b/queries/leo/injections.scm new file mode 100644 index 000000000..321c90add --- /dev/null +++ b/queries/leo/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment"))