From ba4bce9bb79f5a5fb2e7b5a6b9b4b0fb256f3db9 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 7 Mar 2023 04:32:20 -0500 Subject: feat: add Uxn Tal --- README.md | 1 + lockfile.json | 3 ++ lua/nvim-treesitter/parsers.lua | 10 +++++ queries/uxntal/folds.scm | 7 ++++ queries/uxntal/highlights.scm | 84 +++++++++++++++++++++++++++++++++++++++++ queries/uxntal/indents.scm | 17 +++++++++ queries/uxntal/injections.scm | 1 + queries/uxntal/locals.scm | 22 +++++++++++ 8 files changed, 145 insertions(+) create mode 100644 queries/uxntal/folds.scm create mode 100644 queries/uxntal/highlights.scm create mode 100644 queries/uxntal/indents.scm create mode 100644 queries/uxntal/injections.scm create mode 100644 queries/uxntal/locals.scm diff --git a/README.md b/README.md index 6371f7c10..78a228a07 100644 --- a/README.md +++ b/README.md @@ -333,6 +333,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [twig](https://github.com/gbprod/tree-sitter-twig) (maintained by @gbprod) - [x] [typescript](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka) - [x] [ungrammar](https://github.com/Philipp-M/tree-sitter-ungrammar) (maintained by @Philipp-M, @amaanq) +- [x] [uxn tal](https://github.com/amaanq/tree-sitter-uxntal) (maintained by @amaanq) - [x] [v](https://github.com/vlang/vls) (maintained by @kkharji) - [x] [vala](https://github.com/vala-lang/tree-sitter-vala) (maintained by @Prince781) - [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (maintained by @zegervdv) diff --git a/lockfile.json b/lockfile.json index 1f014fefc..2deb48d6b 100644 --- a/lockfile.json +++ b/lockfile.json @@ -479,6 +479,9 @@ "ungrammar": { "revision": "debd26fed283d80456ebafa33a06957b0c52e451" }, + "uxntal": { + "revision": "14e47600afef0affffcbfbe1543381b1ac8fbc5c" + }, "v": { "revision": "66cf9d3086fb5ecc827cb32c64c5d812ab17d2c6" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 1185d02d3..a2fbe23d8 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1520,6 +1520,16 @@ list.ungrammar = { maintainers = { "@Philipp-M", "@amaanq" }, } +list.uxntal = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-uxntal", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "tal", + maintainers = { "@amaanq" }, + readme_name = "uxn tal", +} + list.v = { install_info = { url = "https://github.com/vlang/vls", diff --git a/queries/uxntal/folds.scm b/queries/uxntal/folds.scm new file mode 100644 index 000000000..2043df867 --- /dev/null +++ b/queries/uxntal/folds.scm @@ -0,0 +1,7 @@ +[ + (macro) + (memory_execution) + (subroutine) + + (comment) +] @fold diff --git a/queries/uxntal/highlights.scm b/queries/uxntal/highlights.scm new file mode 100644 index 000000000..25b1148d7 --- /dev/null +++ b/queries/uxntal/highlights.scm @@ -0,0 +1,84 @@ +; Includes + +(include + "~" @include + _ @text.uri @string.special) + +; Macros + +(macro + "%" + (identifier) @function.macro) + +((identifier) @function.macro + (#lua-match? @function.macro "^[a-z]?[0-9]*[A-Z-_]+$")) + +(rune + . rune_start: (rune_char ",") + . (identifier) @function.call) + +(rune + . rune_start: (rune_char ";") + . (identifier) @function.call) + +((identifier) @function.call + (#lua-match? @function.call "^:")) + +; Keywords + +(opcode) @keyword + +; Labels + +(label + "@" @symbol + (identifier) @function) + +(sublabel_reference + (identifier) @namespace + "/" @punctuation.delimiter + (identifier) @label) + +; Repeats + +((identifier) @repeat + (#eq? @repeat "while")) + +; Variables + +(identifier) @variable + +; Literals + +(raw_ascii) @string + +(hex_literal + "#" @symbol + (hex_lit_value) @string.special) + +(number) @number + +; Punctuation + +[ "{" "}" ] @punctuation.bracket + +[ "[" "]" ] @punctuation.bracket + +[ + "%" + "|" + "$" + "," + "_" + "." + "-" + ";" + "=" + "!" + "?" + "&" +] @punctuation.special + +; Comments + +(comment) @comment @spell diff --git a/queries/uxntal/indents.scm b/queries/uxntal/indents.scm new file mode 100644 index 000000000..2802cfd1f --- /dev/null +++ b/queries/uxntal/indents.scm @@ -0,0 +1,17 @@ +(memory_execution) @auto + +[ + (subroutine) + (brackets) +] @indent + +"}" @indent_end + +[ "{" "}" ] @branch + +[ "[" "]" ] @branch + +[ + (ERROR) + (comment) +] @auto diff --git a/queries/uxntal/injections.scm b/queries/uxntal/injections.scm new file mode 100644 index 000000000..4bb7d675d --- /dev/null +++ b/queries/uxntal/injections.scm @@ -0,0 +1 @@ +(comment) @comment diff --git a/queries/uxntal/locals.scm b/queries/uxntal/locals.scm new file mode 100644 index 000000000..0a8ddee96 --- /dev/null +++ b/queries/uxntal/locals.scm @@ -0,0 +1,22 @@ +; Scopes + +[ + (program) + (macro) + (memory_execution) + (subroutine) +] @scope + +; References + +(identifier) @reference + +; Definitions + +(label + "@" + . (identifier) @definition.function) + +(macro + "%" + . (identifier) @definition.macro) -- cgit v1.2.3-70-g09d2