From cab95b2f966561957ca25e3203951fe15139287f Mon Sep 17 00:00:00 2001 From: wzy <32936898+Freed-Wu@users.noreply.github.com> Date: Fri, 9 Feb 2024 16:50:46 +0800 Subject: [PATCH] feat: add tree-sitter-asm parser (#5946) --- README.md | 1 + lockfile.json | 3 ++ lua/nvim-treesitter/parsers.lua | 8 +++++ queries/asm/highlights.scm | 53 +++++++++++++++++++++++++++++++++ queries/asm/injections.scm | 5 ++++ 5 files changed, 70 insertions(+) create mode 100644 queries/asm/highlights.scm create mode 100644 queries/asm/injections.scm diff --git a/README.md b/README.md index 24cc66b58..aec3743bc 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [angular](https://github.com/dlvandenberg/tree-sitter-angular) (experimental, maintained by @dlvandenberg) - [x] [apex](https://github.com/aheber/tree-sitter-sfapex) (maintained by @aheber) - [x] [arduino](https://github.com/ObserverOfTime/tree-sitter-arduino) (maintained by @ObserverOfTime) +- [x] [asm](https://github.com/rush-rs/tree-sitter-asm) (maintained by @RubixDev) - [x] [astro](https://github.com/virchau13/tree-sitter-astro) (maintained by @virchau13) - [x] [authzed](https://github.com/mleonidas/tree-sitter-authzed) (maintained by @mattpolzin) - [ ] [awk](https://github.com/Beaglefoot/tree-sitter-awk) diff --git a/lockfile.json b/lockfile.json index e57c7b318..a44949ec6 100644 --- a/lockfile.json +++ b/lockfile.json @@ -14,6 +14,9 @@ "arduino": { "revision": "ff1045f5da90344d547022c50f1756be4adaf721" }, + "asm": { + "revision": "c7b1167ac0b4ded65850d0751bbbb107ed527566" + }, "astro": { "revision": "e924787e12e8a03194f36a113290ac11d6dc10f3" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 840d53d47..74e0be0f2 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -120,6 +120,14 @@ list.arduino = { maintainers = { "@ObserverOfTime" }, } +list.asm = { + install_info = { + url = "https://github.com/RubixDev/tree-sitter-asm", + files = { "src/parser.c" }, + }, + maintainers = { "@RubixDev" }, +} + list.astro = { install_info = { url = "https://github.com/virchau13/tree-sitter-astro", diff --git a/queries/asm/highlights.scm b/queries/asm/highlights.scm new file mode 100644 index 000000000..341205235 --- /dev/null +++ b/queries/asm/highlights.scm @@ -0,0 +1,53 @@ +; General +(label + (ident) @label) + +(reg) @variable.builtin + +(meta + kind: (_) @function.builtin) + +(instruction + kind: (_) @function.builtin) + +; Comments +[ + (line_comment) + (block_comment) +] @comment @spell + +; Literals +(int) @number + +(float) @number.float + +(string) @string + +; Keywords +[ + "byte" + "word" + "dword" + "qword" + "ptr" + "rel" +] @keyword + +; Operators & Punctuation +[ + "+" + "-" + "*" +] @operator + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +[ + "," + ":" +] @punctuation.delimiter diff --git a/queries/asm/injections.scm b/queries/asm/injections.scm new file mode 100644 index 000000000..3cd6aac8e --- /dev/null +++ b/queries/asm/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment"))