@@ -659,9 +659,12 @@ builtin.buffers({opts}) *builtin.buffers()*
|
|||||||
{only_cwd} (boolean) if true, only show buffers in the
|
{only_cwd} (boolean) if true, only show buffers in the
|
||||||
current working directory (default
|
current working directory (default
|
||||||
false)
|
false)
|
||||||
{sort_lastused} (boolean) if true, sort the shown buffers so
|
{sort_lastused} (boolean) Sorts current and last buffer to the
|
||||||
that the last used one is selected
|
top and selects the lastused
|
||||||
(default false)
|
(default false)
|
||||||
|
{sort_mru} (boolean) Sorts all buffers after most recent
|
||||||
|
used. Not just the current and last
|
||||||
|
one (default false)
|
||||||
{bufnr_width} (number) Defines the width of the buffer
|
{bufnr_width} (number) Defines the width of the buffer
|
||||||
numbers in front of the filenames
|
numbers in front of the filenames
|
||||||
|
|
||||||
|
|||||||
@@ -248,7 +248,8 @@ builtin.reloader = require('telescope.builtin.internal').reloader
|
|||||||
---@field show_all_buffers boolean: if true, show all buffers, including unloaded buffers (default true)
|
---@field show_all_buffers boolean: if true, show all buffers, including unloaded buffers (default true)
|
||||||
---@field ignore_current_buffer boolean: if true, don't show the current buffer in the list (default false)
|
---@field ignore_current_buffer boolean: if true, don't show the current buffer in the list (default false)
|
||||||
---@field only_cwd boolean: if true, only show buffers in the current working directory (default false)
|
---@field only_cwd boolean: if true, only show buffers in the current working directory (default false)
|
||||||
---@field sort_lastused boolean: if true, sort the shown buffers so that the last used one is selected (default false)
|
---@field sort_lastused boolean: Sorts current and last buffer to the top and selects the lastused (default false)
|
||||||
|
---@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
|
---@field bufnr_width number: Defines the width of the buffer numbers in front of the filenames
|
||||||
builtin.buffers = require('telescope.builtin.internal').buffers
|
builtin.buffers = require('telescope.builtin.internal').buffers
|
||||||
|
|
||||||
|
|||||||
@@ -593,6 +593,11 @@ internal.buffers = function(opts)
|
|||||||
return true
|
return true
|
||||||
end, vim.api.nvim_list_bufs())
|
end, vim.api.nvim_list_bufs())
|
||||||
if not next(bufnrs) then return end
|
if not next(bufnrs) then return end
|
||||||
|
if opts.sort_mru then
|
||||||
|
table.sort(bufnrs, function(a, b)
|
||||||
|
return vim.fn.getbufinfo(a)[1].lastused > vim.fn.getbufinfo(b)[1].lastused
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
local buffers = {}
|
local buffers = {}
|
||||||
local default_selection_idx = 1
|
local default_selection_idx = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user