feat(buffers): add buffers_sort option (#2793)
* refactor: add sort_buffers option to buffers picker * refactor: validate sort_buffers opt is a function
This commit is contained in:
@@ -912,6 +912,10 @@ internal.buffers = function(opts)
|
||||
end)
|
||||
end
|
||||
|
||||
if type(opts.sort_buffers) == "function" then
|
||||
table.sort(bufnrs, opts.sort_buffers)
|
||||
end
|
||||
|
||||
local buffers = {}
|
||||
local default_selection_idx = 1
|
||||
for _, bufnr in ipairs(bufnrs) do
|
||||
|
||||
@@ -349,6 +349,7 @@ builtin.reloader = require_on_exported_call("telescope.builtin.__internal").relo
|
||||
---@field sort_mru boolean: Sorts all buffers after most recent used. Not just the current and last one (default: false)
|
||||
---@field bufnr_width number: Defines the width of the buffer numbers in front of the filenames (default: dynamic)
|
||||
---@field file_encoding string: file encoding for the previewer
|
||||
---@field sort_buffers function: sort fn(bufnr_a, bufnr_b). true if bufnr_a should go first. Runs after sorting by most recent (if specified)
|
||||
builtin.buffers = require_on_exported_call("telescope.builtin.__internal").buffers
|
||||
|
||||
--- Lists available colorschemes and applies them on `<cr>`
|
||||
|
||||
Reference in New Issue
Block a user