-
-
Notifications
You must be signed in to change notification settings - Fork 84
Change scopeType matchers to rely on tree-sitter style scheme queries #620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
(object) @map | ||
|
||
(arrow_function) @anonymousFunction | ||
(function) @anonymousFunction | ||
|
||
; We could also have used an alternation here, but the above style is clean and | ||
; seems to be more commonly used. | ||
; [ | ||
; (arrow_function) | ||
; (function) | ||
; ] @anonymousFunction | ||
|
||
; The following doesn't work because we can't have a `(` before the field name (`key`) | ||
; ( | ||
; (object | ||
; (pair | ||
; (key: (_) @key | ||
; . | ||
; ":") @key.removalRange | ||
; ) @key.searchScope | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing to note for all our definitions of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I tried the obvious thing for
And the problem is that for sibling matches, it appears to only return the range of the first sibling, rather than the range of the two siblings. @Will-Sommers / @wenkokke have you seen this kind of thing? Do you know if we can get the full range from the web-tree-sitter api? Here's the output on simplified code. Query:
Code: foo = { bar: "baz", bongo: "bazman" }; Output:
Note that it is paying attention to the trailing sibling, because that's why it only matches the first pair for the first two patterns, but then it doesn't include that trailing sibling in the match range. Hopefully we can just easily get that info when we're using the api instead of the cli There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heyo — I think what we're looking for here is the
yields separate match groups for each kv pair. If we add a Is this what we want?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still isn't grouping the pair and the delim for a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to open a ticket on the main project to check this, alternative in the breach is to check for the presence of a named FYIW, it looks like there are some issues already related to anonymous captures being wonky in the project. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. Fwiw my goal for this specific experiment isn't removal range, but search range. Ie I want the following to work: {foo: "bar", baz: "bongo"} If your cursor is right after the I guess we could use the same workaround we were using for
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, got it. |
||
; ) @key.iterationScope | ||
; ) | ||
|
||
; As a workaround, we could allow defining the end of an annotation | ||
( | ||
(object | ||
(pair | ||
key: (_) @key | ||
. | ||
":" @key.removalRange.end | ||
) @key.searchScope | ||
) @key.iterationScope | ||
) | ||
|
||
; We could instead tag the delimiter itself. Gives us a bit more information, | ||
; so maybe that's better? | ||
( | ||
(object | ||
(pair | ||
key: (_) @key | ||
. | ||
":" @key.delimiter.trailing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Advantage of labelling the delimiter itself is that we can then target it with the "trailing" modifier (#309) Tho we can also do this with the approach below where we use But I think we should prob support all 3 tbh, as they could all be useful for different things There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One question is whether we want to use |
||
) @key.searchScope | ||
) @key.iterationScope | ||
) | ||
|
||
; We could also try setting an attribute. This approach is likely how we'd | ||
; handle comma-separated lists, because they'd be a bit painful to define as | ||
; parse tree patterns | ||
( | ||
(object | ||
(pair | ||
key: (_) @key | ||
(#set! "delimiter" ":") | ||
) @key.searchScope | ||
) @key.iterationScope | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't get this one to work but will prob be useful to have a task or launch config to use while hacking. Maybe
launch.json
is better