feat(nvim): include buf count and cur buf in statusline

This commit is contained in:
Price Hiller 2024-09-21 14:52:16 -05:00
parent 16d56b8ee1
commit 7dc6a0de58
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB

View File

@ -317,6 +317,51 @@ return {
end, end,
} }
local cur_bufs = function()
return vim.iter(vim.api.nvim_list_bufs())
:filter(function(buf)
return vim.fn.buflisted(buf) == 1
end)
:filter(vim.api.nvim_buf_is_loaded)
:filter(vim.api.nvim_buf_is_valid)
:totable()
end
local Buffers = {
update = { "BufNew", "VimEnter", "BufWipeout", "BufUnload", "BufDelete" },
condition = function()
return #cur_bufs() > 0
end,
{
provider = seps.full.left,
hl = { fg = colors.carpYellow, bg = utils.get_highlight("StatusLine").bg },
},
{
provider = function()
return vim.api.nvim_get_current_buf()
end,
hl = { fg = colors.sumiInk0, bg = colors.carpYellow },
},
{
provider = " " .. seps.full.left,
hl = { fg = colors.roninYellow, bg = colors.carpYellow },
},
{
provider = function()
return ("%d  "):format(#cur_bufs())
end,
hl = function()
return {
fg = colors.sumiInk0,
bg = colors.roninYellow,
}
end,
},
{
provider = seps.full.right,
hl = { fg = colors.roninYellow, bg = utils.get_highlight("StatusLine").bg },
},
}
local TabPages = { local TabPages = {
-- only show this component if there's 2 or more tabpages -- only show this component if there's 2 or more tabpages
condition = function() condition = function()
@ -988,6 +1033,7 @@ return {
{ {
provider = "%=", provider = "%=",
}, },
Buffers,
TabPages, TabPages,
}, },
winbar = { winbar = {