From 5c325fe342c26f31df495ec478a1d427270e8e42 Mon Sep 17 00:00:00 2001 From: cgahr Date: Fri, 3 Nov 2023 22:21:54 +0100 Subject: replace kdl tree-sitter to fix highlighting (#8652) * replace kdl tree-sitter * kdl: adopt highlights for new tree-sitter * kdl: add indent queries * kdl: add textobjects * kdl: improve syntax highlighting * kdl: update lang-support * kdl: make indents more concise --------- Co-authored-by: Constantin Gahr --- book/src/generated/lang-support.md | 2 +- languages.toml | 2 +- runtime/queries/kdl/highlights.scm | 8 ++++---- runtime/queries/kdl/indents.scm | 3 +++ runtime/queries/kdl/textobjects.scm | 27 +++++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 runtime/queries/kdl/indents.scm create mode 100644 runtime/queries/kdl/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index c879a967..3b2a115f 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -81,7 +81,7 @@ | jsx | ✓ | ✓ | ✓ | `typescript-language-server` | | julia | ✓ | ✓ | ✓ | `julia` | | just | ✓ | ✓ | ✓ | | -| kdl | ✓ | | | | +| kdl | ✓ | ✓ | ✓ | | | kotlin | ✓ | | | `kotlin-language-server` | | latex | ✓ | ✓ | | `texlab` | | lean | ✓ | | | `lean` | diff --git a/languages.toml b/languages.toml index 24e20654..6e637be7 100644 --- a/languages.toml +++ b/languages.toml @@ -2340,7 +2340,7 @@ injection-regex = "kdl" [[grammar]] name = "kdl" -source = { git = "https://github.com/Unoqwy/tree-sitter-kdl", rev = "e1cd292c6d15df6610484e1d4b5c987ecad52373" } +source = { git = "https://github.com/amaanq/tree-sitter-kdl", rev = "3ca569b9f9af43593c24f9e7a21f02f43a13bb88" } [[language]] name = "xml" diff --git a/runtime/queries/kdl/highlights.scm b/runtime/queries/kdl/highlights.scm index d83bde19..78e5acf4 100644 --- a/runtime/queries/kdl/highlights.scm +++ b/runtime/queries/kdl/highlights.scm @@ -1,12 +1,12 @@ -(comment) @comment (single_line_comment) @comment +(multi_line_comment) @comment (node - name: (identifier) @function) + (identifier) @variable) + (prop (identifier) @attribute) -(type) @type -(bare_identifier) @variable.other.member +(type (_) @type) @punctuation.bracket (keyword) @keyword diff --git a/runtime/queries/kdl/indents.scm b/runtime/queries/kdl/indents.scm new file mode 100644 index 00000000..bc2ffc15 --- /dev/null +++ b/runtime/queries/kdl/indents.scm @@ -0,0 +1,3 @@ +(node_children) @indent + + "}" @outdent diff --git a/runtime/queries/kdl/textobjects.scm b/runtime/queries/kdl/textobjects.scm new file mode 100644 index 00000000..7f9a562c --- /dev/null +++ b/runtime/queries/kdl/textobjects.scm @@ -0,0 +1,27 @@ +(type (_) @test.inside) @test.around + +(node + children: (node_children)? @class.inside) @class.around + +(node + children: (node_children)? @function.inside) @function.around + +(node (identifier) @function.movement) + +[ + (single_line_comment) + (multi_line_comment) +] @comment.inside + +[ + (single_line_comment)+ + (multi_line_comment)+ +] @comment.around + +[ + (prop) + (value) +] @parameter.inside + +(value (type) ? (_) @parameter.inside @parameter.movement . ) @parameter.around + -- cgit v1.2.3-70-g09d2