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

feat: use treesitter Query for building Positions #13

Merged

Conversation

cristianoliveira
Copy link
Contributor

@cristianoliveira cristianoliveira commented Aug 27, 2023

Playing with the tree-sitter is quite fun :)

I figured tree-sitter comes with a built-in query feature, I'm not sure it is more performant than the current implementation, I didn't test it, but I'd place my bet on that.

I used this for reference:
https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries

Also their unit tests https://github.com/tree-sitter/tree-sitter/blob/master/cli/src/tests/query_test.rs

I didn't remove the dead code, I just kept it as a comparison, but accordingly with the tests, they are behaving the same. This implementation also contains the fix for #11

This implementation doesn't address the suggesting when editing an attribute in the middle of other hx-*
For instance:

<div hx-get="/foo" hx-target="<cursor here>" hx-swap="next"></div>

(cherry picked from commit 68d1b7df2eaba904bbf40e04ad1ac5bb496081b7)
@ThePrimeagen
Copy link
Owner

you are freaking awesome

i love queries (i just didn't want to have to relearn everything for them) this looks perfect.

@ThePrimeagen
Copy link
Owner

the tests look great and the queries look great too

@ThePrimeagen ThePrimeagen merged commit e2f8dfe into ThePrimeagen:master Aug 28, 2023
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.

None yet

2 participants