rebelot/heirline.nvim

Is there a way to hide tab/bufbar on initial nvim open, when only one buffer and file exists?

Closed this issue · 4 comments

The statusline and winbar both show the filename by default also, further reducing the utility of having it visible in this situation.

Sorry for making so many issues. I realize a couple of these could have been better placed in Discussions.

There's an option called showtabline, and setting it to 1 might fit what you need. You can read more about it in :h 'showtabline'

You can do something like this. Will probably add to the cookbook

-- from the cookbook
local buf_cache = {} -- this
local BufferLine = utils.make_buflist(
    TablineBufferBlock,
    { provider = "", hl = { fg = "gray" } },
    { provider = "", hl = { fg = "gray" } }, nil,
    buf_cache -- this
)

vim.api.nvim_create_autocmd({"BufAdd", "BufDelete"}, {
    callback = function()
        if #buf_cache > 1 then
            vim.o.showtabline = 2
        else
            vim.o.showtabline = 1
        end
    end
})

I apologise, the presented snippet does not fully work as intended.