Skip to content

How to set tabline in Lua? #24131

Closed Answered by otakutyrant
otakutyrant asked this question in Q&A
Discussion options

You must be logged in to vote

I read the document again and found out I cannot use the code from the QA immediately. After struggling with Lua codes I finnaly made it:

-- ## Tabline, defines how tabpages title looks like
-- For convenience of cross-probjects development, show project names directly.
function MyTabLine()
    local tabline = ""
    for index = 1, vim.fn.tabpagenr('$') do
        -- select the highlighting
        if index == vim.fn.tabpagenr() then
            tabline = tabline .. '%#TabLineSel#'
        else
            tabline = tabline .. '%#TabLine#'
        end

        -- set the tab page number (for mouse clicks)
        tabline = tabline .. '%' .. index .. 'T'

        local win_num = vim.fn.tab…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@otakutyrant
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by otakutyrant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants