Skip to content
Merged
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
6 changes: 4 additions & 2 deletions data/fixtures/recorded/languages/clojure/chuckItemZip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ finalState:
documentContents: |-
{
:foo "bar",
;; hello
,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This trailing comma with the four spaces of indentation looks a bit weird, could we make this look better? The other tests are clearly improvements

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is unfortunately quite hard. If the comment wasn't there the comma would be cleaned up. The whole thing about dealing with comments is something I intend to do in the future, but for now I think we will have to make due with this implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Let's make sure we file it at some point

}
selections:
- anchor: {line: 2, character: 1}
active: {line: 2, character: 1}
- anchor: {line: 4, character: 1}
active: {line: 4, character: 1}
4 changes: 3 additions & 1 deletion data/fixtures/recorded/languages/clojure/clearItemBat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ initialState:
finalState:
documentContents: |-
{
,

;; hello
"whatever",
}
selections:
- anchor: {line: 1, character: 4}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ initialState:
start: {line: 0, character: 2}
end: {line: 0, character: 5}
finalState:
documentContents: "{}"
documentContents: "{ :baz \"whatever\"}"
selections:
- anchor: {line: 0, character: 1}
active: {line: 0, character: 1}
50 changes: 44 additions & 6 deletions queries/clojure.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

;; A list is either a vector literal or a quoted list literal
(vec_lit) @list

(quoting_lit
(list_lit)
) @list
Expand All @@ -17,27 +18,64 @@
(list_lit
(_)? @_.leading.endOf
.
(_) @collectionItem.start
(_) @collectionItem
.
(_)? @_.trailing.startOf
)

(list_lit
open: "(" @collectionItem.iteration.start.startOf
close: ")" @collectionItem.iteration.end.endOf
open: "(" @collectionItem.iteration.start.endOf
close: ")" @collectionItem.iteration.end.startOf
) @collectionItem.iteration.domain

;;!! [foo bar]
;;! ^^^ ^^^
(vec_lit
(_)? @_.leading.endOf
.
(_) @collectionItem.start
(_) @collectionItem
.
(_)? @_.trailing.startOf
)

(vec_lit
open: "[" @collectionItem.iteration.start.startOf
close: "]" @collectionItem.iteration.end.endOf
open: "[" @collectionItem.iteration.start.endOf
close: "]" @collectionItem.iteration.end.startOf
) @collectionItem.iteration.domain

;; Keyword follow by a value
(map_lit
(_)? @_.leading.endOf
.
(kwd_lit) @collectionItem.start
.
value: (_) @collectionItem.end
.
(_)? @_.trailing.startOf
)

;; Keyword followed by comment or closing brace
(map_lit
(_)? @_.leading.endOf
.
(kwd_lit) @collectionItem.start
.
[
(comment) @_.trailing.startOf
"}"
]
)

;; Non keyword value that is not preceded by a keyword. eg a string literal.
(map_lit
_ @_dummy
.
value: (_) @collectionItem
(#not-type? @_dummy "kwd_lit")
(#not-type? @collectionItem "kwd_lit")
)

(map_lit
open: "{" @collectionItem.iteration.start.endOf
close: "}" @collectionItem.iteration.end.startOf
) @collectionItem.iteration.domain
Loading