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

Option to include adjacent nodes when sorting #5

Open
sid-6581 opened this issue Aug 18, 2024 · 2 comments
Open

Option to include adjacent nodes when sorting #5

sid-6581 opened this issue Aug 18, 2024 · 2 comments

Comments

@sid-6581
Copy link

My main use case for sorting is things like functions. The problem with that is everything isn't usually nested neatly under a single node, things like comments and attributes can be at the same level as the function declaration. Here is an example in rust:

image

As you can see from this tree, the function node is preceded by the comment and attribute nodes:

image

What I'd love to be able to do is sort all function_item nodes at the same level by name, and include any preceding nodes that belong with the function.

@mtrajano
Copy link
Owner

This is a very interesting idea and I think something that can be useful for people. I'll look into adding this and comment here with the pr for you to look at. Any ideas for the config key for it? Something like sibling_nodes or anchor_nodes that will take a list of possible nodes that should move with it?

@sid-6581
Copy link
Author

Great, thanks! Maybe include_sibling_nodes could work? I think with a name like that it would be pretty self-descriptive.

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

2 participants