Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stabline] [FEAT]: Add tab index #62

Open
bogdan-the-great opened this issue Mar 8, 2024 · 2 comments
Open

[stabline] [FEAT]: Add tab index #62

bogdan-the-great opened this issue Mar 8, 2024 · 2 comments

Comments

@bogdan-the-great
Copy link

Make bufferline (stabline) to have a tab indicator at the right side, where it would show current tab number and other tabs like buffers dimmed. Basically make it look like in nvim-bufbar or in bufferline.nvim. Would be nice to show only numbers when there are more than one tabs in the session.

I think that it would make the stabline more complete and useful with this update.

Screenshot:
image

@tamton-aquib
Copy link
Owner

Adding that should be simple but the styling is whats difficult 😅.
But I'll try to do it this weekend.

Meanwhile you could try something with stab_end temporarily, for example:

require("stabline").setup({ stab_end="%{tabpagenr()}" })

@bogdan-the-great
Copy link
Author

An example solution from nvim-bufbar:

local function get_tabs()
    local tabs = {}
    local current_tab = fn.tabpagenr()

    for _, tabinfo in ipairs(fn.gettabinfo()) do
        local tab = {
            tabnr = tabinfo.tabnr,
            current = tabinfo.tabnr == current_tab,
        }

        table.insert(tabs, tab)
    end

    return tabs
end

...
    if M.options.show_tabs then
        local tabs, tablist = get_tabs(), {}

        for _, tab in ipairs(tabs) do
            local level = tab.current and 'active' or 'inactive'
            local tabname = set_hlgroup(fmt(' %d ', tab.tabnr), 'tabs', level)

            table.insert(tablist, tabname)
        end

        table.insert(bufferline, table.concat(tablist, separator))
    end
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants