From 6b24db0c8fc1357522320e71c89069fdc66a4237 Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Tue, 21 Nov 2023 02:19:07 +0200 Subject: [PATCH] feat: add properties parser --- README.md | 1 + lockfile.json | 3 +++ lua/nvim-treesitter/parsers.lua | 9 +++++++++ queries/properties/highlights.scm | 28 ++++++++++++++++++++++++++++ queries/properties/injections.scm | 2 ++ queries/properties/locals.scm | 3 +++ 6 files changed, 46 insertions(+) create mode 100644 queries/properties/highlights.scm create mode 100644 queries/properties/injections.scm create mode 100644 queries/properties/locals.scm diff --git a/README.md b/README.md index 559ae50da..bf96df17a 100644 --- a/README.md +++ b/README.md @@ -328,6 +328,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [pony](https://github.com/amaanq/tree-sitter-pony) (maintained by @amaanq, @mfelsche) - [x] [prisma](https://github.com/victorhqc/tree-sitter-prisma) (maintained by @elianiva) - [x] [promql](https://github.com/MichaHoffmann/tree-sitter-promql) (maintained by @MichaHoffmann) +- [x] [properties](https://github.com/ObserverOfTime/tree-sitter-properties) (maintained by @ObserverOfTime) - [x] [proto](https://github.com/treywood/tree-sitter-proto) (maintained by @treywood) - [x] [prql](https://github.com/PRQL/tree-sitter-prql) (maintained by @matthias-Q) - [x] [psv](https://github.com/amaanq/tree-sitter-csv) (maintained by @amaanq) diff --git a/lockfile.json b/lockfile.json index 94ad3a190..9e1bf1ae3 100644 --- a/lockfile.json +++ b/lockfile.json @@ -464,6 +464,9 @@ "promql": { "revision": "77625d78eebc3ffc44d114a07b2f348dff3061b0" }, + "properties": { + "revision": "97253273bdf8b63546c8006e71ba155ecc27069e" + }, "proto": { "revision": "e9f6b43f6844bd2189b50a422d4e2094313f6aa3" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index dc9135698..b012d514a 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1385,6 +1385,15 @@ list.promql = { maintainers = { "@MichaHoffmann" }, } +list.properties = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-properties", + files = { "src/parser.c" }, + }, + filetype = "jproperties", + maintainers = { "@ObserverOfTime" }, +} + list.proto = { install_info = { url = "https://github.com/treywood/tree-sitter-proto", diff --git a/queries/properties/highlights.scm b/queries/properties/highlights.scm new file mode 100644 index 000000000..3414294b7 --- /dev/null +++ b/queries/properties/highlights.scm @@ -0,0 +1,28 @@ +(comment) @comment @spell + +(key) @property + +(value) @string + +(value (escape) @string.escape) + +((value) @boolean + (#any-of? @boolean "true" "false")) + +((value) @number + (#lua-match? @number "^%d+$")) + +(index) @number + +(property [ "=" ":" ] @operator) + +[ "${" "}" ] @punctuation.special + +(substitution ":" @punctuation.special) + +[ "[" "]" ] @punctuation.bracket + +[ "." "\\" ] @punctuation.delimiter + +((substitution (key) @constant) + (#lua-match? @constant "^[A-Z_][A-Z0-9_]*$")) diff --git a/queries/properties/injections.scm b/queries/properties/injections.scm new file mode 100644 index 000000000..321c90add --- /dev/null +++ b/queries/properties/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/queries/properties/locals.scm b/queries/properties/locals.scm new file mode 100644 index 000000000..d9360c465 --- /dev/null +++ b/queries/properties/locals.scm @@ -0,0 +1,3 @@ +(property (key) @definition) + +(substitution (key) @reference)