Keybinding/command to change file sorting method on-the-fly #1922
Replies: 4 comments 6 replies
|
You can customise the sorting with your own function, see You can define a mapping to flip between your desired sort configrurations. Here's a complete example: #1566 (comment) We should add a recipe for this to the wiki. I'd be most grateful if you could do :) |
|
doesn't it make sense to have something like |
local sorter_string = "name"
local sorter_function = function(nodes)
return sorter_string
end
local sort_by_time = function ()
sorter_string = "modification_time"
require('nvim-tree.api').tree.reload()
end
local sort_by_name = function ()
sorter_string = "name"
require('nvim-tree.api').tree.reload()
end
require("nvim-tree").setup({
sort = { sorter = sorter_function }
})just passing a string should not require that much boilerplate imo |
Uh oh!
There was an error while loading. Please reload this page.
I'd love to be able to, e.g., quickly switch to a "recently modified" sort at times, but don't want that to always be the default.
Is this currently doable? Not sure if it's possible (or even desirable) to call
setup()multiple times with different params via a keybinding, or if there would be an easier way.Thanks!
All reactions