Skip to content

Introduce tree-sitter queries for syntactic scopes #629

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

Merged
merged 25 commits into from
Apr 19, 2023

Conversation

Will-Sommers
Copy link
Collaborator

@Will-Sommers Will-Sommers commented Apr 8, 2022

Todo

@pokey
Copy link
Member

pokey commented Apr 8, 2022

Shouldn't we use https://github.com/nvim-treesitter/tree-sitter-query instead of scheme?

@pokey
Copy link
Member

pokey commented Apr 8, 2022

Also worth mentioning https://marketplace.visualstudio.com/items?itemName=jrieken.vscode-tree-sitter-query, which defines a language id for tree sitter queries

@Will-Sommers
Copy link
Collaborator Author

sg!

@Will-Sommers Will-Sommers changed the title Add two basic scopes for Scheme using queries [WIP] Start adding default scope types based off of TS-Query language May 3, 2022
Copy link
Member

@pokey pokey left a comment

Choose a reason for hiding this comment

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

Just publishing a few random comments here

Copy link
Member

@pokey pokey left a comment

Choose a reason for hiding this comment

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

nice progress 😊. Definitely pretty clean / readable syntax. Left a few nits

Copy link
Member

@pokey pokey left a comment

Choose a reason for hiding this comment

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

Haven't read whole PR yet but here's some comments

@pokey
Copy link
Member

pokey commented May 24, 2022

As discussed in meet-up, algorithm is as follows:

  1. Split range into start and end position
  2. For the start position
    1. Find smallest domain that contains or is adjacent to position
    2. If there are two such nodes, pick the one to the right
  3. If the end position is contained or adjacent to the domain returned in previous step, return the tagged range
  4. Otherwise, run steps 2.1 and 2.2 on the end node
  5. If the start position is contained or adjacent to domain returned in previous step, return the tagged range
  6. Otherwise, return the range from the start tagged range to the end tagged range, with direction taken from selection

@Will-Sommers Will-Sommers changed the title [WIP] Start adding default scope types based off of TS-Query language Initial work for scopeType matchers based on Tree-Sitter's Query DSL May 25, 2022
@Will-Sommers Will-Sommers marked this pull request as ready for review May 25, 2022 19:18
@pokey pokey changed the base branch from main to pokey/issue69-Support-fully-compositional-modifiers May 27, 2022 16:33
@pokey pokey linked an issue May 31, 2022 that may be closed by this pull request
@pokey pokey force-pushed the scheme-scope-demo branch 2 times, most recently from 772442c to f775401 Compare April 17, 2023 15:42
@pokey pokey force-pushed the scheme-scope-demo branch from f775401 to ecaf27f Compare April 17, 2023 15:56
@pokey pokey marked this pull request as draft April 17, 2023 16:58
@pokey
Copy link
Member

pokey commented Apr 18, 2023

Ok this one is good to go, but unfortunately it breaks "every funk" for Ruby. I created #1430 to fix that issue. That PR is ready, so would be great if you could have a look when you get a minute. I think they should prob merge in together so we don't break "every funk" in Ruby on main

@pokey pokey mentioned this pull request Apr 18, 2023
3 tasks
@pokey pokey removed the to discuss Plan to discuss at meet-up label Apr 18, 2023
@pokey pokey marked this pull request as ready for review April 19, 2023 10:36
@pokey pokey added this pull request to the merge queue Apr 19, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 19, 2023
@pokey pokey added this pull request to the merge queue Apr 19, 2023
Merged via the queue into cursorless-dev:main with commit 467f699 Apr 19, 2023
pokey added a commit that referenced this pull request Apr 19, 2023
- Adds `@_.domain`, `@_.leading`, `@_.trailing`, `@_.removal`, and
`@_.interior` tree-sitter query captures
- Introduces `@_.iteration` tree-sitter query capture to allow
indicating iteration scope for tree-sitter scope handlers
- Depends on #629

## 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
AndreasArvidsson pushed a commit that referenced this pull request Jun 17, 2023
)

This PR adds a test to ensure that we don't try to define the same scope
type both using our legacy node matchers and the new query scope
handlers

I have mixed feelings about the way I made this work, but I wasn't sure
how else to do it. The test needs to be defined in the engine, because
otherwise we'd need to expose lots of stuff to cursorless-vscode-e2e,
but it needs a full tree-sitter instance, so can't be run as a unit
test. This file is the compromise I came up with 🤷‍♂️. We should maybe
revise once we have tree-sitter integrated with this repo

I don't like that this code gets rolled up into our production bundle,
but probably ok for this one-off. If we find this file growing, we
should revisit

It's also possible that once we get rid of our `ide` singleton, we can
relax the restriction that our test harness doesn't import from
`cursorless-engine`. That would enable us to just import what we need
from the engine directly in the test harness to run this test 🤔

- Depends on #629

## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants