Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
537 changes: 172 additions & 365 deletions topiary-cli/tests/samples/expected/tree_sitter_query.scm

Large diffs are not rendered by default.

241 changes: 79 additions & 162 deletions topiary-queries/queries/bash.scm

Large diffs are not rendered by default.

55 changes: 18 additions & 37 deletions topiary-queries/queries/css.scm
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
(string_value)
(color_value)
(float_value)
(grid_value)
] @leaf
(grid_value)] @leaf

; Append space after colons
(declaration ":" @append_space)
(feature_query
":" @append_space
)
":" @append_space)

; Append space after import
(import_statement "@import" @append_space)
Expand All @@ -37,12 +35,10 @@

; Space around and in binary queries
(binary_query
"and" @prepend_space @append_space
)
"and" @prepend_space @append_space)
; Space around not in unary queries
(unary_query
"not" @append_space
)
"not" @append_space)

; Add space before any !important declarations
(important) @prepend_space
Expand All @@ -61,78 +57,65 @@
(descendant_selector
(_) @append_space
.
(_)
)
(_))
(sibling_selector
(_) @append_space
"~" @append_space
(_)
)
(_))
(adjacent_sibling_selector
(_) @append_space
"+" @append_space
(_)
)
(_))
(child_selector
(_) @append_space
">" @append_space
(_)
)
(_))

; Indent the declarations in the block
(block
.
"{" @append_hardline @append_indent_start @prepend_space
(_)
"}" @prepend_hardline @prepend_indent_end @append_hardline
.
)
.)

; Indent the declarations in the keyframe_block_list
(keyframe_block_list
.
"{" @append_hardline @append_indent_start @prepend_space
(_)
"}" @prepend_hardline @prepend_indent_end @append_hardline
.
)
.)

; Always have semicolon after declarations
(
(declaration) @append_delimiter
(#delimiter! ";")
(#not-match? @append_delimiter ";$")
)
(#not-match? @append_delimiter ";$"))

; Appends hardline between declaration
(declaration
";" @append_hardline
)
";" @append_hardline)

; Add space between values after a property name
(declaration
(property_name)
":" @append_space
(_) @append_space
)
(_) @append_space)

; Do not add a space between the last value and the ending semicolon
(declaration
";" @prepend_antispace
)
";" @prepend_antispace)

(declaration
"," @prepend_antispace @append_space
)
"," @prepend_antispace @append_space)

(arguments
"," @append_space
)
"," @append_space)

; Newline between selectors
(selectors
"," @append_hardline
)
"," @append_hardline)

; Space between operators in binary expressions
(binary_expression ["+" "*" "-" "/"] @append_space @prepend_space)
Expand All @@ -142,6 +125,4 @@
(arguments
(_) @append_space
.
["," ")"]* @do_nothing
)
)
["," ")"]* @do_nothing))
12 changes: 4 additions & 8 deletions topiary-queries/queries/json.scm
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,22 @@
"{" @append_spaced_softline @append_indent_start
(pair)
"}" @prepend_spaced_softline @prepend_indent_end
.
)
.)

(array
.
"[" @append_spaced_softline @append_indent_start
(_value)
"]" @prepend_spaced_softline @prepend_indent_end
.
)
.)

; Pairs should always end with a softline.
; Pairs come in two kinds, ones with a trailing comma, and those without.
; Those without are the last pair of an object,
; and the line is already added by the closing curly brace of the object.
(object
"," @append_spaced_softline
)
"," @append_spaced_softline)

; Items in an array must have a softline after. See also the pairs above.
(array
"," @append_spaced_softline
)
"," @append_spaced_softline)
Loading
Loading