From aad763de6ba7d5fbc93377d2d20cae7e374a466b Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sat, 28 Jan 2023 07:59:56 -0500 Subject: feat: add kdl (#4227) * feat: add kdl * feat: comment queries * fix(kdl): comments properly highlighted now * feat(kdl): folds * chore: bump revision to feature-complete parser * fix: folds --- README.md | 1 + lockfile.json | 3 +++ lua/nvim-treesitter/parsers.lua | 10 ++++++++ queries/kdl/folds.scm | 3 +++ queries/kdl/highlights.scm | 55 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 queries/kdl/folds.scm create mode 100644 queries/kdl/highlights.scm diff --git a/README.md b/README.md index 8281244c6..eb1628e8c 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [JSON with comments](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git) (maintained by @WhyNotHugo) - [x] [jsonnet](https://github.com/sourcegraph/tree-sitter-jsonnet) (maintained by @nawordar) - [x] [julia](https://github.com/tree-sitter/tree-sitter-julia) (maintained by @theHamsta) +- [x] [kdl](https://github.com/amaanq/tree-sitter-kdl) (experimental, maintained by @amaanq) - [x] [kotlin](https://github.com/fwcd/tree-sitter-kotlin) (maintained by @SalBakraa) - [x] [lalrpop](https://github.com/traxys/tree-sitter-lalrpop) (maintained by @traxys) - [x] [latex](https://github.com/latex-lsp/tree-sitter-latex) (maintained by @theHamsta, @clason) diff --git a/lockfile.json b/lockfile.json index 99c54cb9f..2bb73f024 100644 --- a/lockfile.json +++ b/lockfile.json @@ -218,6 +218,9 @@ "julia": { "revision": "9d368185be7e8139f2eda93d8b0acc2a54031718" }, + "kdl": { + "revision": "3a67244a48e9446248fc48117afe11dab19b030a" + }, "kotlin": { "revision": "e4637037a5fe6f25fe66c305669faa0855f35692" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 6c9ba5265..f5d1abad8 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -374,6 +374,16 @@ list.java = { maintainers = { "@p00f" }, } +list.kdl = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-kdl", + branch = "master", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, + experimental = true, +} + list.kotlin = { install_info = { url = "https://github.com/fwcd/tree-sitter-kotlin", diff --git a/queries/kdl/folds.scm b/queries/kdl/folds.scm new file mode 100644 index 000000000..04a2ba28e --- /dev/null +++ b/queries/kdl/folds.scm @@ -0,0 +1,3 @@ +; Folds + +(node_children) @fold diff --git a/queries/kdl/highlights.scm b/queries/kdl/highlights.scm new file mode 100644 index 000000000..0ef693d5a --- /dev/null +++ b/queries/kdl/highlights.scm @@ -0,0 +1,55 @@ +; Types + +(node (identifier) @type) + +(type) @type + +(annotation_type) @type.builtin + +; Properties + +(prop (identifier) @property) + +; Variables + +(identifier) @variable + +; Operators +[ + "=" + "+" + "-" +] @operator + +; Literals + +(string) @string + +(escape) @string.escape + +(number) @number + +(number (decimal) @float) +(number (exponent) @float) +(number (decimal) (exponent) @float) + +(boolean) @boolean + +; Misc + +"null" @constant.builtin + +["{" "}"] @punctuation.bracket + +["(" ")"] @punctuation.bracket + +; Comments + +[ + (single_line_comment) + (multi_line_comment) +] @comment + +(node (node_comment) (#set! "priority" 105)) @comment +(node (node_field (node_field_comment) (#set! "priority" 105)) @comment) +(node_children (node_children_comment) (#set! "priority" 105)) @comment -- cgit v1.2.3-70-g09d2