From af8f6e740bb82ba743fee97bd5be5898d9c3eef8 Mon Sep 17 00:00:00 2001 From: romanschulz <33926896+romanschulz@users.noreply.github.com> Date: Wed, 27 Mar 2024 09:41:07 +0100 Subject: [PATCH 1/3] adjust the calculation of which tabs can be displayed --- lua/nvchad/tabufline/modules.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvchad/tabufline/modules.lua b/lua/nvchad/tabufline/modules.lua index 0ec28b2e..25d385a6 100644 --- a/lua/nvchad/tabufline/modules.lua +++ b/lua/nvchad/tabufline/modules.lua @@ -62,7 +62,7 @@ M.buffers = function() local has_current = false -- have we seen current buffer yet? for i, nr in ipairs(vim.t.bufs) do - if ((#buffers + 1) * 23) > available_space() then + if ((#buffers + 1) * 21) > available_space() then if has_current then break end From 23958b3dd2633def2496087abae45f00afdd12b7 Mon Sep 17 00:00:00 2001 From: romanschulz <33926896+romanschulz@users.noreply.github.com> Date: Wed, 27 Mar 2024 09:41:49 +0100 Subject: [PATCH 2/3] modify the padding calculation for a tab length of 21 characters --- lua/nvchad/tabufline/utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvchad/tabufline/utils.lua b/lua/nvchad/tabufline/utils.lua index 432d0eef..cacd804a 100644 --- a/lua/nvchad/tabufline/utils.lua +++ b/lua/nvchad/tabufline/utils.lua @@ -61,7 +61,7 @@ M.style_buf = function(nr, i) end -- padding around bufname; 15= maxnamelen + 2 icon & space + 2 close icon - local pad = math.floor((23 - #name - 5) / 2) + local pad = math.floor((21 - #name - 5) / 2) pad = pad <= 0 and 1 or pad local maxname_len = 15 From bcd096498ab0eb5ff6b017cf3d1b7a89bc78e138 Mon Sep 17 00:00:00 2001 From: Roman Schulz Date: Wed, 27 Mar 2024 11:15:05 +0100 Subject: [PATCH 3/3] constant with buffer width equals to 21 --- lua/nvchad/tabufline/modules.lua | 5 +++-- lua/nvchad/tabufline/utils.lua | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/nvchad/tabufline/modules.lua b/lua/nvchad/tabufline/modules.lua index 25d385a6..b6f22255 100644 --- a/lua/nvchad/tabufline/modules.lua +++ b/lua/nvchad/tabufline/modules.lua @@ -10,6 +10,7 @@ local strep = string.rep local style_buf = require("nvchad.tabufline.utils").style_buf local cur_buf = api.nvim_get_current_buf local config = require("nvconfig").ui.tabufline +local BUF_WIDTH = 21 ---------------------------------------------------------- btn onclick functions ---------------------------------------------- @@ -62,7 +63,7 @@ M.buffers = function() local has_current = false -- have we seen current buffer yet? for i, nr in ipairs(vim.t.bufs) do - if ((#buffers + 1) * 21) > available_space() then + if ((#buffers + 1) * BUF_WIDTH) > available_space() then if has_current then break end @@ -71,7 +72,7 @@ M.buffers = function() end has_current = cur_buf() == nr or has_current - table.insert(buffers, style_buf(nr, i)) + table.insert(buffers, style_buf(nr, i, BUF_WIDTH)) end return table.concat(buffers) .. txt("%=", "Fill") -- buffers + empty space diff --git a/lua/nvchad/tabufline/utils.lua b/lua/nvchad/tabufline/utils.lua index cacd804a..c54933e9 100644 --- a/lua/nvchad/tabufline/utils.lua +++ b/lua/nvchad/tabufline/utils.lua @@ -40,7 +40,7 @@ local function gen_unique_name(oldname, index) end end -M.style_buf = function(nr, i) +M.style_buf = function(nr, i, width) -- add fileicon + name local icon = "󰈚" local is_curbuf = cur_buf() == nr @@ -61,7 +61,7 @@ M.style_buf = function(nr, i) end -- padding around bufname; 15= maxnamelen + 2 icon & space + 2 close icon - local pad = math.floor((21 - #name - 5) / 2) + local pad = math.floor((width - #name - 5) / 2) pad = pad <= 0 and 1 or pad local maxname_len = 15