tabline-framework.nvim icon indicating copy to clipboard operation
tabline-framework.nvim copied to clipboard

How to show tabline with only one tab

Open javeoff opened this issue 2 years ago • 5 comments

How to show buffers in tabline, when only one tab is opened?

I use tabline_framework.toys and do not know how to do this.

javeoff avatar Apr 18 '22 09:04 javeoff

Do you mean that tabline is not showing when there is only one tab? In that case, you can set nvim to always show tabline by setting vim.opt.showtabline = 2

Or is there another error? Could you provide some more details, your config, maybe screenshot if that's not it?

rafcamlet avatar Apr 19 '22 17:04 rafcamlet

@rafcamlet yes, but in my case prefer to show tabline is only one tab and when buffers more than one

javeoff avatar Apr 19 '22 19:04 javeoff

when nvim just opened, do not show tabline. If then open more buffers or create a tab, it must shown

javeoff avatar Apr 19 '22 20:04 javeoff

Hi @javeoff ! Wow, it took me a while to get back. I'm trying, but unfortunately, I'm still not sure what you mean. If you are still interested in getting help with the problem, please describe it step by step in more detail.

rafcamlet avatar Jan 04 '23 19:01 rafcamlet

I know it's almost a year after the last reply, but:

	vim.api.nvim_create_autocmd(
		{ "VimEnter", "BufNew", "BufReadPost", "BufDelete", "BufWipeout" },
		{
			callback = function()
				vim.defer_fn(function()
					local getCount = function()
						local result =
							vim.api.nvim_exec2("ls", { output = true })

						local count = 1
						for _ in string.gmatch(result.output, "\n") do
							count = count + 1
						end

						return count
					end
					print(getCount())

					if getCount() <= 1 then
						vim.cmd("set showtabline=0")
					else
						vim.cmd("set showtabline=2")
					end
				end, 1)
			end,
		}
	)

Does what @javeoff wants, I believe. I just threw this in the config function for tabline-framework and it seems to work alright. Hides tabline if only one buffer, shows tabline if there's more than one.

distek avatar Jan 07 '24 20:01 distek