Skip to content

Commit f7436d9

Browse files
authored
Clean up talon.scm based on tree-sitter-talon 4.0 (#2005)
See wenkokke/tree-sitter-talon#42 ## Checklist - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [-] I have not broken the cheatsheet
1 parent bfac727 commit f7436d9

File tree

2 files changed

+12
-34
lines changed

2 files changed

+12
-34
lines changed

packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@ class NotType extends QueryPredicateOperator<NotType> {
1919
}
2020
}
2121

22-
/**
23-
* A predicate operator that returns true if the nodes range is not empty.
24-
*/
25-
class NotEmpty extends QueryPredicateOperator<NotEmpty> {
26-
name = "not-empty?" as const;
27-
schema = z.tuple([q.node]);
28-
run({ range }: MutableQueryCapture) {
29-
return !range.isEmpty;
30-
}
31-
}
32-
3322
/**
3423
* A predicate operator that returns true if the node's parent is not of the
3524
* given type. For example, `(not-parent-type? @foo string)` will reject the
@@ -208,7 +197,6 @@ class InsertionDelimiter extends QueryPredicateOperator<InsertionDelimiter> {
208197
export const queryPredicateOperators = [
209198
new Log(),
210199
new NotType(),
211-
new NotEmpty(),
212200
new NotParentType(),
213201
new IsNthChild(),
214202
new ChildRange(),

queries/talon.scm

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,11 @@
2525
(parrot_declaration)
2626
] @statement
2727

28-
(
29-
[
30-
(matches)
31-
(declarations)
32-
(block)
33-
] @statement.iteration
34-
35-
;; The Talon Tree sitter can contain an empty matches node if there is no
36-
;; header. When this happens and the user has an empty cursor at the start of
37-
;; the document we get an empty range for the iteration scope for
38-
;; key/value/name/statement.
39-
(#not-empty? @statement.iteration)
40-
)
28+
[
29+
(matches)
30+
(declarations)
31+
(block)
32+
] @statement.iteration
4133

4234
;;!! not mode: command
4335
;;! ----^^^^---------
@@ -107,15 +99,13 @@
10799
;;! -------------
108100
;;!! foo: key(a)
109101
;;! -----------]
110-
(
111-
(source_file
112-
(matches) @condition @_.trailing
113-
) @_.domain
114-
(#not-empty? @condition)
115-
(#not-empty? @_.trailing)
116-
(#shrink-to-match! @condition "^(?<keep>.*)(\s|\n|\r)+-$")
117-
(#shrink-to-match! @_.trailing "^.*(?<keep>(\s|\n|\r)+-)$")
118-
)
102+
(source_file
103+
(matches
104+
(_) @condition.end.endOf
105+
.
106+
"-" @_.trailing
107+
) @condition.start.startOf
108+
) @_.domain
119109

120110
;;!! slap: key(enter)
121111
;;! ^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)