folke / edgy.nvim

Easily create and manage predefined window layouts, bringing a new edge to your workflow
Apache License 2.0
783 stars 14 forks source link

`opts.[direction].title` should accept string and function #59

Closed tummetott closed 2 weeks ago

tummetott commented 8 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

It would be awesome if opts.[direction].title can accept a string and a function (the functions must return a string).

Two use cases:

bottom = {
    {
        -- Indicate in the windbar which help file is currently open
        title = function() local bufname = vim.api.nvim_buf_get_name(0)
            bufname = vim.fn.fnamemodify(bufname, ':t')
            return string.format('HELP: %s', bufname)
        end,
        ft = 'help',
    },
    {
        -- Indicate whether the location list or quickfix list is currently
        -- displayed
        title = function()
            local loclist = vim.fn.getwininfo(vim.fn.win_getid())[1]['loclist'] == 1
            return loclist and 'LOCATION LIST' or 'QUICKFIX LIST'
        end,
        ft = 'qf',
    }
}

Describe the solution you'd like

opts.[direction].title accepts string and function

Describe alternatives you've considered

Disabling the winbar winbar = false for a filetype and handling it manually with my winbar plugin. However this is a workaround and i'd love to handle all the winbar titles in edgy.nvim

Additional context

No response

tummetott commented 8 months ago

I realized I can solve the second use case with the filter() function:

{
    title = 'QUICKFIX LIST',
    filter = function(_, win)
        return vim.fn.getwininfo(win)[1]['loclist'] ~= 1
    end,
    ft = 'qf',
},
{
    title = 'LOCATION LIST',
    filter = function(_, win)
        return vim.fn.getwininfo(win)[1]['loclist'] == 1
    end,
    ft = 'qf',
},

However, in cases where a single filetype covers various instances, like help documents and manpages, it would be very helpful to have the filename or bufname included in the winbar information. This feature request is kindly submitted for consideration, aiming to enhance user experience.

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.