feat: add support for function in max_length option (tabs & buffers)

This commit is contained in:
Shadman 2021-10-29 19:07:11 +06:00
parent 96263bcef6
commit ecaa491c3c
3 changed files with 10 additions and 0 deletions

View File

@ -413,6 +413,7 @@ sections = {
show_filename_only = true, -- shows shortened relative path when false
show_modified_status = true -- shows indicator then bufder is modified
max_length = vim.o.columns * 2 / 3, -- maximum width of buffers component
-- can also be a function that returns value of max_length dynamicaly
filetype_names = {
TelescopePrompt = 'Telescope',
dashboard = 'Dashboard',
@ -538,6 +539,7 @@ sections = {
{
'tabs',
max_length = vim.o.columns / 3, -- maximum width of tabs component
-- can also be a function that returns value of max_length dynamicaly
mode = 0, -- 0 shows tab_nr
-- 1 shows tab_name
-- 2 shows tab_nr + tab_name

View File

@ -93,6 +93,10 @@ function M:update_status()
end
local max_length = self.options.max_length
if type(max_length) == 'function' then
max_length = max_length(self)
end
if max_length == 0 then
max_length = math.floor(2 * vim.o.columns / 3)
end

View File

@ -76,6 +76,10 @@ function M:update_status()
end
local max_length = self.options.max_length
if type(max_length) == 'function' then
max_length = max_length(self)
end
if max_length == 0 then
max_length = math.floor(vim.o.columns / 3)
end