Skip to content

Commit

Permalink
Update tree-sitter-query formatting to handle changes
Browse files Browse the repository at this point in the history
* This also changes our TOML queries
* Also made minor comment adjustments to the Bash queries
  • Loading branch information
Xophmeister committed Jan 16, 2025
1 parent ec9f6dc commit 53b32b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions topiary-queries/queries/bash.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
; any which are encountered by Topiary will be forcibly collapsed on to
; a single line. (See Issue #172)

; Don't modify strings, heredocs, comments, atomic "words" or variable
; expansions (simple or otherwise)
; Don't modify strings, heredocs, comments, atomic "words", variable
; expansions or array indices.
[
(comment)
(expansion)
Expand Down
6 changes: 4 additions & 2 deletions topiary-queries/queries/toml.scm
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@

; remove trailing comma from last element of single line array
(array
("," @delete . "]")(#single_line_only!)
("," @delete . "]")
(#single_line_only!)
)

; add trailing comma if absent to last string of multiline array
(array
(((string) @append_delimiter) . ","* @do_nothing . (comment)? . "]")(#delimiter! ",")
(((string) @append_delimiter) . ","* @do_nothing . (comment)? . "]")
(#delimiter! ",")
(#multi_line_only!)
)

Expand Down
5 changes: 5 additions & 0 deletions topiary-queries/queries/tree_sitter_query.scm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
_ @allow_blank_line_before @prepend_hardline
)

(predicate) @allow_blank_line_before

; There is a large category of nodes that must be separated by spaces
(
[
Expand Down Expand Up @@ -45,6 +47,7 @@
"_"
]
)

(anonymous_node
(capture) @prepend_space
)
Expand Down Expand Up @@ -98,6 +101,7 @@
[
(anonymous_node)
(field_definition)
(grouping)
(list)
(named_node)
(predicate)
Expand All @@ -107,6 +111,7 @@
[
(anonymous_node)
(field_definition)
(grouping)
(list)
(named_node)
(predicate)
Expand Down

0 comments on commit 53b32b4

Please sign in to comment.