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

Using Tree-sitter predicates requires us to use Topiary capture names #824

Open
Xophmeister opened this issue Jan 6, 2025 · 0 comments
Open

Comments

@Xophmeister
Copy link
Member

Tree-sitter comes with a bunch of built-in predicates, which work using the capture names. However, in Topiary, we only allow our formatting capture names, such as @append_hardline, etc. While these work in the predicates, it makes them a bit strange to read. For example:

; Append a space to (foo (bar)) nodes if they begin with a capital letter
(foo
  (bar) @append_space

  (#match? @append_space "[A-Z].*")
)

While this would just be a nice-to-have, maybe it would be worthwhile whitelisting certain patterns for capture names that have no formatting functionality, but make the predicates more intuitive. For example, allowing @topiary\..+:

(foo
  (bar) @topiary.foobar @append_space

  (#match? @topiary.foobar "[A-Z].*")
)

A potential issue with this is that, IIRC, the number of capture names per node is limited to something unreasonably small (like 3).

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

No branches or pull requests

1 participant