famiu / feline.nvim

A minimal, stylish and customizable statusline for Neovim written in Lua
GNU General Public License v3.0
1.04k stars 55 forks source link

Mouse click support for winbar #280

Open mehalter opened 2 years ago

mehalter commented 2 years ago

Hey I just have a quick question, I saw your Neovim improvement to add click support to winbar @famiu ! Very impressive work and I'm really excited to give it a try. I was just wondering if any of that functionality has made it to feline yet.

Thanks so much for all your Neovim work!

famiu commented 2 years ago

Hey I just have a quick question, I saw your Neovim improvement to add click support to winbar @famiu ! Very impressive work and I'm really excited to give it a try. I was just wondering if any of that functionality has made it to feline yet.

Thanks so much for all your Neovim work!

I could implement it now but in all honesty it would be very messy and I'm not quite sure how I'd manage to integrate it properly with how Feline currently generates a statusline. I plan to make a PR to Neovim in the future that allows using Lua callbacks and tables to configure the statusline. So I was originally planning on finishing that first and then adding click support to Feline.

Though, if really needed, I could give a shot at implementing it now, but there will be lots of gotchas and limitations (e.g.: You may not be able to have more than 50 clickable items in a statusline due to a (Neo-)Vim limitation).

mehalter commented 2 years ago

No worries! I'm in no rush, was just seeing if there was anything available yet. Thanks for the status update!

famiu commented 2 years ago

Let's keep this open until the feature is implemented

MunifTanjim commented 1 year ago
Do not follow the tips in this comment. It was experimental and might be removed later. Until Neovim supports lua callback for statusline clicks, if you have `nui.nvim` installed already, you can use this: https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/bar#coreclickable ```lua local core = require("nui.bar.core") local function on_click(_, click_count, mouse_button, modifiers, ctx) print(ctx.tabid, ctx.winid, ctx.bufnr, ctx.is_focused) print(ctx.ctx.hello) end -- then make provider for feline local clickable_provider = core.clickable("CLICK ME", { context = { hello = "world" }, on_click = on_click, }) ```
luukvbaal commented 1 year ago

Neovim already supports lua statusline click callbacks through v:lua.

MunifTanjim commented 1 year ago

Ah, global and module functions are of course supported (as soon as Famiu landed that click support). 😂

What I shared is just a convenient wrapper around that feature that generates the statusline format string for clicking.

luukvbaal commented 1 year ago

Cool, yeah seems useful👍🏻 The way you phrased it seemed like you were waiting for some kind of support in Neovim. I'm not sure if it can be made more convenient in core.

EDIT: I guess you were referencing what famiu said above

MunifTanjim commented 1 year ago

I guess you were referencing what famiu said above

Yeah, should've mentioned I was referencing to the discussion above 😃