Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Mouse click support for winbar #280

Open
mehalter opened this issue Jun 1, 2022 · 8 comments
Open

Mouse click support for winbar #280

mehalter opened this issue Jun 1, 2022 · 8 comments

Comments

@mehalter
Copy link

mehalter commented Jun 1, 2022

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
Copy link
Owner

famiu commented Jun 1, 2022

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
Copy link
Author

mehalter commented Jun 1, 2022

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

@mehalter mehalter closed this as completed Jun 1, 2022
@famiu
Copy link
Owner

famiu commented Jun 1, 2022

Let's keep this open until the feature is implemented

@famiu famiu reopened this Jun 1, 2022
@MunifTanjim
Copy link

MunifTanjim commented Dec 29, 2022

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

@luukvbaal
Copy link

luukvbaal commented Dec 29, 2022

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

@MunifTanjim
Copy link

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
Copy link

luukvbaal commented Dec 29, 2022

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
Copy link

I guess you were referencing what famiu said above

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

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

No branches or pull requests

4 participants