Open sid-6581 opened 1 month ago
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?
Great, thanks! Maybe include_sibling_nodes
could work? I think with a name like that it would be pretty self-descriptive.
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:
As you can see from this tree, the function node is preceded by the comment and attribute nodes:
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.