local set = require("rabbit.plugins.util") ---@class Rabbit.Plugin.Buffers.Options ---@field public ignore_unlisted? boolean If true, will ignore unlisted buffers (like Oil) ---@class Rabbit.Plugin.Buffers: Rabbit.Plugin local M = { ---@type Rabbit.Plugin color = "#1ae5d4", name = "buffers", func = {}, switch = "b", listing = {}, empty_msg = "No opened buffers", skip_same = true, keys = {}, evt = {}, ---@param p Rabbit.Plugin.Buffers init = function(p) p.listing[0] = {} p.listing.paths = {} end, ---@type Rabbit.Plugin.Buffers.Options opts = { -- ignore_unlisted = true, }, } local get_buffers = function() M.listing.paths = {} M.listing[0] = {} local bufs = vim.fn.getbufinfo({ buflisted = 1 }) -- table.sort(bufs, function(a, b) -- return a.lastused < b.lastused -- end) for _, b in ipairs(bufs) do set.add(M.listing.paths, b.bufnr) set.add(M.listing[0], b.name) end end function M.evt.RabbitEnter() get_buffers() end ---@param n integer function M.func.file_del(n) vim.print(M.listing.paths[n]) -- vim.cmd("bd " .. tostring(M.listing.paths[n])) -- table.remove(M.listing, n) end return M