feline.nvim icon indicating copy to clipboard operation
feline.nvim copied to clipboard

Mouse click support for winbar

Open mehalter opened this issue 2 years ago • 8 comments

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!

mehalter avatar Jun 01 '22 12:06 mehalter

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).

famiu avatar Jun 01 '22 12:06 famiu

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

mehalter avatar Jun 01 '22 12:06 mehalter

Let's keep this open until the feature is implemented

famiu avatar Jun 01 '22 12:06 famiu

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

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,
})

MunifTanjim avatar Dec 29 '22 19:12 MunifTanjim

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

luukvbaal avatar Dec 29 '22 19:12 luukvbaal

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.

MunifTanjim avatar Dec 29 '22 20:12 MunifTanjim

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

luukvbaal avatar Dec 29 '22 20:12 luukvbaal

I guess you were referencing what famiu said above

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

MunifTanjim avatar Dec 29 '22 21:12 MunifTanjim