Skip to content
Discussion options

You must be logged in to vote

'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:

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),
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by echasnovski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested mini.tabline
2 participants