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

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

Open
1 task done
tummetott opened this issue Nov 12, 2023 · 1 comment · May be fixed by #90
Open
1 task done

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

tummetott opened this issue Nov 12, 2023 · 1 comment · May be fixed by #90
Labels
enhancement New feature or request

Comments

@tummetott
Copy link

tummetott commented Nov 12, 2023

Did you check the docs?

  • I have read all the edgy.nvim 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 tummetott added the enhancement New feature or request label Nov 12, 2023
@tummetott tummetott changed the title opts.[direction].title should accept string **and function** opts.[direction].title should accept string and function Nov 12, 2023
@tummetott
Copy link
Author

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.

gj86 added a commit to gj86/edgy.nvim that referenced this issue Jun 21, 2024
Accept and use function as view title. This provides option to implement per view dynamic/context based title.
@gj86 gj86 linked a pull request Jun 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant