Work on select function
parent
d653d5cbce
commit
fcb2339b53
|
|
@ -5,7 +5,7 @@ local set = require("rabbit.plugins.util")
|
|||
|
||||
---@class Rabbit.Plugin.Buffers: Rabbit.Plugin
|
||||
local M = { ---@type Rabbit.Plugin
|
||||
color = "#d08e95",
|
||||
color = "#1ae5d4",
|
||||
name = "buffers",
|
||||
func = {},
|
||||
switch = "b",
|
||||
|
|
@ -31,52 +31,40 @@ local M = { ---@type Rabbit.Plugin
|
|||
},
|
||||
}
|
||||
|
||||
function M.evt.RabbitEnter()
|
||||
local get_buffers = function()
|
||||
M.listing.paths = {}
|
||||
M.listing[0] = {}
|
||||
local bufs = vim.api.nvim_list_bufs()
|
||||
|
||||
local bufs = vim.fn.getbufinfo({ buflisted = 1 })
|
||||
table.sort(bufs, function(a, b)
|
||||
return a.bufnr > b.bufnr
|
||||
end)
|
||||
|
||||
for _, b in ipairs(bufs) do
|
||||
local path = vim.api.nvim_buf_get_name(b)
|
||||
set.add(M.listing.paths, path)
|
||||
set.add(M.listing[0], path)
|
||||
set.add(M.listing.paths, { bufnr = b.bufnr, lnum = b.lnum })
|
||||
set.add(M.listing[0], b.name)
|
||||
end
|
||||
end
|
||||
-- function M.evt.BufEnter(evt, winid)
|
||||
-- local is_listed = vim.api.nvim_get_option_value("buflisted", { buf = evt.buf })
|
||||
-- if M.opts.ignore_unlisted and not is_listed then
|
||||
-- return
|
||||
-- end
|
||||
-- set.add(M.listing[winid], evt.buf)
|
||||
-- set.add(M.listing.opened, evt.buf)
|
||||
-- end
|
||||
|
||||
-- function M.evt.BufDelete(evt, winid)
|
||||
-- set.sub(M.listing[winid], evt.buf)
|
||||
-- set.sub(M.listing.opened, evt.buf)
|
||||
-- end
|
||||
|
||||
function M.evt.WinClosed(_, winid)
|
||||
-- if M.listing[winid] ~= nil and #M.listing[winid] > 0 then
|
||||
-- M.listing.last_closed = M.listing[winid]
|
||||
-- end
|
||||
-- M.listing[winid] = nil
|
||||
function M.evt.RabbitEnter()
|
||||
get_buffers()
|
||||
end
|
||||
|
||||
---@param n integer
|
||||
function M.func.select(n)
|
||||
-- ---@param n integer
|
||||
-- function M.func.select(n)
|
||||
-- local rabbit = require("rabbit")
|
||||
-- if M.listing[0] == nil or n ~= 1 then
|
||||
-- return rabbit.func.select(n)
|
||||
-- end
|
||||
--
|
||||
-- M.listing[0] = rabbit.ctx.listing
|
||||
-- table.remove(M.listing[0], 1)
|
||||
-- M.listing[rabbit.user.win] = M.listing[0]
|
||||
-- vim.api.nvim_win_set_buf(rabbit.user.win, tonumber(M.listing[0][1]) or 0)
|
||||
-- M.listing[0] = nil
|
||||
--
|
||||
-- rabbit.func.close()
|
||||
end
|
||||
-- --
|
||||
-- -- M.listing[0] = rabbit.ctx.listing
|
||||
-- -- table.remove(M.listing[0], 1)
|
||||
-- -- M.listing[rabbit.user.win] = M.listing[0]
|
||||
-- -- vim.api.nvim_win_set_buf(rabbit.user.win, tonumber(M.listing[0][1]) or 0)
|
||||
-- -- M.listing[0] = nil
|
||||
-- -- vim.api.nvim_set_current_buf(M.listing.paths
|
||||
-- -- rabbit.func.close()
|
||||
-- end
|
||||
|
||||
---@param n integer
|
||||
function M.func.file_del(n)
|
||||
|
|
|
|||
Loading…
Reference in New Issue