From 2563fa4d71d1c384e12d2668739a45b89b68f6dc Mon Sep 17 00:00:00 2001 From: milanglacier Date: Fri, 1 Nov 2024 03:03:18 -0400 Subject: [PATCH] feat: add option `always_show_tabline` to control whether show `tabline` when there are only one tab. (#1013) * feat: add option `always_show_tabline`. --------- Co-authored-by: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> --- README.md | 5 +++++ lua/lualine.lua | 2 +- lua/lualine/config.lua | 1 + tests/spec/lualine_spec.lua | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 238b283b8..7605da61b 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ require('lualine').setup { }, ignore_focus = {}, always_divide_middle = true, + always_show_tabline = true, globalstatus = false, refresh = { statusline = 1000, @@ -378,6 +379,10 @@ options = { -- can't take over the entire statusline even -- if neither of 'x', 'y' or 'z' are present. + always_show_tabline = true -- When set to true, if you have configured lualine for displaying tabline + -- then tabline will always show. If set to false, then tabline will be displayed + -- only when there are more than 1 tab. (see :h showtabline) + globalstatus = false, -- enable global statusline (have a single statusline -- at bottom of neovim instead of one for every window). -- This feature is only available in neovim 0.7 and higher. diff --git a/lua/lualine.lua b/lua/lualine.lua index 609304929..0e3b1b4dd 100644 --- a/lua/lualine.lua +++ b/lua/lualine.lua @@ -479,7 +479,7 @@ local function set_tabline(hide) "call v:lua.require'lualine'.refresh({'kind': 'tabpage', 'place': ['tabline'], 'trigger': 'autocmd'})", 'lualine_tal_refresh' ) - modules.nvim_opts.set('showtabline', 2, { global = true }) + modules.nvim_opts.set('showtabline', config.options.always_show_tabline and 2 or 1, { global = true }) timers.halt_tal_refresh = false else modules.nvim_opts.restore('tabline', { global = true }) diff --git a/lua/lualine/config.lua b/lua/lualine/config.lua index cc92099d9..56f56ecb7 100644 --- a/lua/lualine/config.lua +++ b/lua/lualine/config.lua @@ -18,6 +18,7 @@ local config = { }, ignore_focus = {}, always_divide_middle = true, + always_show_tabline = true, globalstatus = vim.go.laststatus == 3, refresh = { statusline = 1000, diff --git a/tests/spec/lualine_spec.lua b/tests/spec/lualine_spec.lua index eb46a3ce1..b3990f784 100644 --- a/tests/spec/lualine_spec.lua +++ b/tests/spec/lualine_spec.lua @@ -21,6 +21,7 @@ describe('Lualine', function() }, ignore_focus = {}, always_divide_middle = true, + always_show_tabline = true, globalstatus = false, refresh = { statusline = 1000,