Skip to content
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

Text object using ad-hoc tree-sitter queries from nodes under cursor #84

Open
bew opened this issue Apr 30, 2022 · 0 comments
Open

Text object using ad-hoc tree-sitter queries from nodes under cursor #84

bew opened this issue Apr 30, 2022 · 0 comments

Comments

@bew
Copy link
Owner

bew commented Apr 30, 2022

CRAZY IDEA:

A kind of interactive text object maker, usable as a text object.

Problem

With code:

while (line := text_lines[0]):
    # cursor here ~~^

I want to select text_lines[0], the assignment value of the variable.
Possible resolution:

  • A dedicated text object for the current expression, but that would probably just select text_lines,
    (edit: or maybe not?)
  • A dedicated text object for the value of assignment, but that would eat a key for a very specific use case, hard to find test object keys for all use cases..
    (edit: unless it's moved behind a treesitter-node-specific operator? tv instead of just v 🤔)
  • Select the text the-old-way: bvt) (no semantics), BAD because not be reliable in a macro if value is a function call..
    (e.g on while (line := foo(bar)))
  • Make a dedicated selection using auto extend/shrink like in vscode/IDEs, but it's not repeatable, and can't be used to extend selection if Add generic visual selection _extension_ using existing text objects #83 is implemented.

Crazy solution

Trigger a custom text object, that checks nodes under cursor and suggest queries to choose from (could be edited on the fly? with preview) to select the wanted text.
The used text-object could then be saved and repeated in some cases (which ones?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

1 participant