Hide tabline when there is less than 1 tab #1686
-
Contributing guidelines
Module(s)mini.tabline QuestionIs there a way to hide the tabline when there is no tab open ? I tried to do an auto command but it didn't work: vim.api.nvim_create_autocmd({ "TabNew", "TabClosed" }, {
desc = "Hide the tabline when empty",
group = group,
callback = function()
local show = #vim.api.nvim_list_tabpages() > 1
vim.opt.showtabline = show and 2 or 0
end,
})
|
Beta Was this translation helpful? Give feedback.
Answered by
echasnovski
Mar 18, 2025
Replies: 1 comment
-
'mini.tabline' shows listed buffers instead of tab (a.k.a. tabpages, see local get_n_listed_bufs = function()
local n = 0
for _, buf_id in ipairs(vim.api.nvim_list_bufs()) do
n = n + (vim.bo[buf_id].buflisted and 1 or 0)
end
return n
end
vim.api.nvim_create_autocmd({ 'BufAdd', 'BufDelete' }, {
desc = 'Hide the tabline when empty',
group = group,
-- Schedule because 'BufDelete' is triggered when buffer is still present
callback = vim.schedule_wrap(function() vim.o.showtabline = get_n_listed_bufs() > 1 and 2 or 0 end),
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
echasnovski
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'mini.tabline' shows listed buffers instead of tab (a.k.a. tabpages, see
:h window
).I'd it is rare to have only a single listed buffer opened when working with Neovim, but it can be done with something like this: