Skip to content

Commit

Permalink
replace kdl tree-sitter to fix highlighting (helix-editor#8652)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
2 people authored and mtoohey31 committed Jun 2, 2024
1 parent 5f6a80b commit 56f0792
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
| jsx |||| `typescript-language-server` |
| julia |||| `julia` |
| just |||| |
| kdl || | | |
| kdl || | | |
| kotlin || | | `kotlin-language-server` |
| latex ||| | `texlab` |
| lean || | | `lean` |
Expand Down
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions runtime/queries/kdl/highlights.scm
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions runtime/queries/kdl/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(node_children) @indent

"}" @outdent
27 changes: 27 additions & 0 deletions runtime/queries/kdl/textobjects.scm
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 56f0792

Please sign in to comment.