bew / dotfiles

All my dotfiles in one place!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

bew opened this issue · comments

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,
  • 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..
  • Select the text the-old-way: bvt) (no semantics), may not be reliable in a macro
    (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 #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?)