Adding tab information to statusline #1508
-
Contributing guidelines
Module(s)mini.statusline QuestionI don't like to use a dedicated tabline, opting to have an indicator for the tabs in the statusline instead. With the lualine plugin, it has a "tabs" option which would show one number for each tab, with your current tab being highlighted. I was wondering if there is an easy way to get tab information into mini.statusline, like getting "current tab number | total tab number" similar to how it has "current row number | total row number". I'm not sure if there's an easy way to add that section to the existing config or if I'd have to redefine a bunch of defaults or something. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@KodyVB Does this work for you? |
Beta Was this translation helpful? Give feedback.
-
As @krovuxdev suggested, using local content_active = function()
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
local git = MiniStatusline.section_git({ trunc_width = 40 })
local diff = MiniStatusline.section_diff({ trunc_width = 75 })
local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })
local lsp = MiniStatusline.section_lsp({ trunc_width = 75 })
local filename = MiniStatusline.section_filename({ trunc_width = 140 })
local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
local location = MiniStatusline.section_location({ trunc_width = 75 })
local search = MiniStatusline.section_searchcount({ trunc_width = 75 })
local tabpage_info = vim.fn.tabpagenr() .. '│' .. vim.fn.tabpagenr('$')
return MiniStatusline.combine_groups({
{ hl = mode_hl, strings = { mode } },
{ hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } },
'%<', -- Mark general truncate point
{ hl = 'MiniStatuslineFilename', strings = { filename } },
'%=', -- End left alignment
{ hl = 'MiniStatuslineFileinfo', strings = { fileinfo } },
{ hl = mode_hl, strings = { search, location, tabpage_info } },
})
end
require('mini.statusline').setup({ content = { active = content_active } }) |
Beta Was this translation helpful? Give feedback.
As @krovuxdev suggested, using
vim.fn.tabpagenr()
is the way here. For example, like this: