Skip to content

Commit

Permalink
fix no hl bug; add option to ignore unlisted buffers like oil
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxelPrismatic committed Jun 6, 2024
1 parent 0f057d1 commit 74c1028
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/rabbit/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions lua/rabbit/plugins/history.lua
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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

Expand Down

0 comments on commit 74c1028

Please sign in to comment.