Description
Discussed in https://github.com/nvim-tree/nvim-tree.lua/discussions/2727
Originally posted by rennsax March 27, 2024
We can use the option sort.sorter
to customize how the files are sorted. If a function is provided, the argument is a table of all nodes. After sorted by the user's function, nvim-tree still needs to perform merge sort on the result.
I just found the interface is too complex to customize (not to mention the performance issue) when I was trying to tweak nvim-tree to put some special files (like CMakeLists.txt
) at the end.
Firstly, the interface can be more elegant if it just requires a function that compare two nodes with necessary information and return a boolean value indicating which one should precede. And the implementation of this function will be much more clear.
Secondly, I suggest that nvim-tree/explorer/sorts.lua could export some function utility for file sorting to ease the complexity of writing the comparing logic from scratch.
Is this a better design?