Skip to content

Current node highlight preview functionality #39

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

Open
kuator opened this issue May 20, 2025 · 3 comments
Open

Current node highlight preview functionality #39

kuator opened this issue May 20, 2025 · 3 comments
Labels
baking Waiting to see if this is functionality desired by many feature request

Comments

@kuator
Copy link

kuator commented May 20, 2025

Currently, without treesitter-unit, it's not possible to determine the syntax node the user is currently located in. This is why installing treesitter-unit becomes necessary. However, this functionality is fundamental and would be a strong candidate for inclusion as a built-in feature.

Here's a demo showcasing a potential implementation of a treewalker with highlight preview enabled:

Peek.2025-05-20.20-56.mp4
@kuator kuator changed the title A demo of highlight preview? Current node highlight preview? May 20, 2025
@kuator kuator changed the title Current node highlight preview? Current node highlight preview functionality May 20, 2025
@aaronik aaronik added the enhancement New feature or request label May 20, 2025
@aaronik
Copy link
Owner

aaronik commented May 20, 2025

Awesome - thank you for the ticket. I'm thinking on the best way forward on this now.

@aaronik aaronik added feature request and removed enhancement New feature or request labels May 22, 2025
@aaronik
Copy link
Owner

aaronik commented May 23, 2025

Alright @kuator I have what probably amounts to a half fix:

Previously, if you set Treewalker's highlight_duration option to something high, and you moved around quickly, you'd see a bunch of highlights accumulating simultaneously - it kind of defeated the purpose as your whole file would look highlighted. Not a great user experience.

Now, if you set it similarly high and move around quickly, all previous highlights get removed before applying any new ones. So if you move exclusively with treewalker, this similates highlighting the node that would be swapped.

However, if you move onto a node without using treewalker, then the highlight will not be applied. This is why it's probably a half fix.

Adding a listener against all movement would add a massive performance cost to movement by just having Treewalker installed, so I don't want to do that.

And since treesitter-unit already exists and is great, I don't want to reimplement its functionality. Every new piece of functionality in Treewalker is a new piece of functionality to maintain and fix bugs against. So I think it's good to keep plugins tight and focused, doing only what they originally set out to do.

So for now this is going to have to suffice. Unless you have any other ideas!

@aaronik aaronik added the baking Waiting to see if this is functionality desired by many label May 23, 2025
@aaronik
Copy link
Owner

aaronik commented May 23, 2025

Note this is similar to #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
baking Waiting to see if this is functionality desired by many feature request
Projects
None yet
Development

No branches or pull requests

2 participants