diff --git a/lua/rabbit/defaults.lua b/lua/rabbit/defaults.lua index a15e7cc..1cfe78a 100644 --- a/lua/rabbit/defaults.lua +++ b/lua/rabbit/defaults.lua @@ -41,6 +41,9 @@ local box = { local function grab_color(name) local details = vim.api.nvim_get_hl(0, { name = name }) + if details == nil or details.fg == nil then + return nil + end return string.format("#%06x", details.fg) end diff --git a/lua/rabbit/plugins/history.lua b/lua/rabbit/plugins/history.lua index 5ccece4..06494ba 100644 --- a/lua/rabbit/plugins/history.lua +++ b/lua/rabbit/plugins/history.lua @@ -1,6 +1,12 @@ local set = require("rabbit.plugins.util") +---@class Rabbit.Plugin.History.Options +---@field public ignore_unlisted? boolean If true, will ignore unlisted buffers (like Oil) + + ---@type Rabbit.Plugin +---@class Rabbit.Plugin.History +---@field opts Rabbit.Plugin.History.Options local M = { color = "#d7827e", name = "history", @@ -12,11 +18,17 @@ local M = { keys = {}, evt = {}, init = function(_) end, + opts = { + ignore_unlisted = false + } } ---@param evt NvimEvent ---@param winid integer function M.evt.BufEnter(evt, winid) + if M.opts.ignore_unlisted and not vim.fn.getbufinfo(evt.buf)[1].listed then + return + end set.add(M.listing[winid], evt.buf) end