Skip to content

Tabline

windwp edited this page Sep 5, 2021 · 1 revision

tabline

It display all Tab not buffer.

you can customize to any theme. the default theme of tabline is similar to nvim-bufferline

default

windline.setup({
  tabline = {}
})

you can change theme by change component in template

custom

require('windline').setup({
    tabline = {
        template = {
            -- this use a highlight color a text will replace by tab name
            select        = {''                           , {'TabSelectionFg' , 'TabSelectionBg'}},
            select_start  = {''                           , {'TabLineBg'      , 'TabSelectionBg'}},
            select_end    = {separator.slant_right .. ' ' , {'TabSelectionBg' , 'TabLineBg'}},

            -- select_last display if select tab is a last tab
            select_last   = {separator.slant_right        , {'TabSelectionBg' , 'TabLineFillBg'}},


            -- this only use a highlight color a text will replace by tab name
            normal        = {''                           , {'TabLineFg'      , 'TabLineBg'}},
            normal_start  = {' '                          , {'TabLineFg'      , 'TabLineBg'}},
            normal_end    = {separator.slant_right_thin   , {'TabLineFg'      , 'TabLineBg'}},

            -- normal_select display if a next tab is select
            normal_select = {separator.slant_right .. ' ' , {'TabLineBg','TabSelectionBg' }},
            -- normal_last display if tab is the last tab
            normal_last   = {separator.slant_right        , {'TabLineBg', 'TabLineFillBg' }},
        },
    }
})

custome 2

        template = {
            select        = {''                    , {'TabSelectionFg' , 'TabSelectionBg'}} ,
            select_start  = {separator.slant_left  , {'TabSelectionBg' , 'TabLineFillBg'}}  ,
            select_end    = {separator.slant_right , {'TabSelectionBg' , 'TabLineFillBg'}}  ,
            select_last   = {separator.slant_right , {'TabSelectionBg' , 'TabLineFillBg'}}  ,
            normal        = {''                    , {'TabLineFg'      , 'TabLineBg'}}      ,
            normal_start  = {separator.slant_left  , {'TabLineBg'      , 'TabLineFillBg'}}  ,
            normal_end    = {separator.slant_right , {'TabLineBg'      , 'TabLineFillBg'}}  ,
            normal_last   = {separator.slant_right , {'TabLineBg'      , 'TabLineFillBg' }} ,
            normal_select = {separator.slant_right , {'TabLineBg'      , 'TabLineFillBg' }} ,
        },

component in template can be a function (It can't return a group of component)

  -- this sample display a total window on that tab end
require('windline').setup({
    tabline = {
        template = {
            normal_end = {
                function(data)
                    return vim.fn.tabpagewinnr(data.tab_index,'$')
                end,
                { 'blue', 'red' },
            },
        },
    },
})
-- you can render a list of component after all tab display
require('windline').setup({
tabline ={
  tab_end = {
        { '%=', { 'NormalFg', 'NormalBg' } },
        {
            function(tab_index)
                return vim.fn.tabpagewinnr(tab_index, '$')
            end,
            { 'green', 'NormalBg' },
        },
        {
            function()
                return ' ' .. vim.fn.strftime('%H:%M:%S') .. ' '
            end,
            { 'red', 'NormalBg' },
        },
  }}
})

code_tabline

Clone this wiki locally